简体   繁体   English

无法在 Google Cloud 平台上使用 docker 安装作曲家 - 出现错误无法打开输入文件:artisan

[英]Can't install composer with docker on Google Cloud platform - Getting error Could not open input file: artisan

I am trying to build laravel project with docker on Google cloud platform.我正在尝试在 Google 云平台上使用 docker 构建 laravel 项目。 I am getting Could not open input file: artisan error in Google logs.我收到Could not open input file: artisan错误。 I have tried all solutions out there, unfortunately none of them is working:(我已经尝试了所有解决方案,不幸的是它们都不起作用:(

Here is my DockerFile这是我的 DockerFile

FROM php:8.1

ENV PORT 8080

RUN apt update
RUN apt install wget
RUN apt-get update
RUN apt-get install -y git
RUN apt-get install -y zip
RUN apt-get install -y unzip
RUN apt-get install -y curl

RUN docker-php-ext-install pdo pdo_mysql

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --2

WORKDIR /app

COPY composer.json .

RUN composer install

RUN apt-get update && apt-get install -y \
    software-properties-common \
    npm
RUN npm install npm@latest -g && \
    npm install n -g && \
    n latest

COPY . .

CMD php artisan serve --host=0.0.0.0 --port 8080

After building it using docker command locally, I get this error Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1 in the terminal.在本地使用 docker 命令构建它后,我收到此错误Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1 in the terminal.

在此处输入图像描述

Also, I have the artisan file in my root project folder.另外,我的根项目文件夹中有 artisan 文件。

在此处输入图像描述

I have exactly the same variables in Google Cloud platform variables as well.我在谷歌云平台变量中也有完全相同的变量。 My.env file is below. My.env 文件如下。

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:+ly4U3QbWcULnj0A31g41q7Yim/L0W5olgwPbsuD1/A=
APP_DEBUG=true
APP_URL=http://127.0.0.1:8080

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=test
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=testdb
DB_USERNAME=root
DB_PASSWORD=root

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

Please tell me what am I missing?请告诉我我错过了什么?

You have to first COPY. .你必须先COPY. . COPY. . and then run composer install ...然后运行composer install ...

I do not recommend to have CMD php artisan serve as your image driver... just have another container like NGINX or Apache...我不建议让CMD php artisan serve作为你的图像驱动程序......只要有另一个容器,如 NGINX 或 Apache......

I also do not recommend installing and doing stuff in the image creation... running composer install is not part of an image, and if it is, you have to be very careful, as if the composer part fails, you have no image to do something with php...我也不建议在图像创建中安装和做任何事情......运行composer install不是图像的一部分,如果是,你必须非常小心,就好像 composer 部分失败了,你没有图像用 php 做点什么……


Why do you have to COPY. .为什么你必须COPY. . COPY. . before composer install ?composer install之前? Because you have nothing on the image being built, you only have composer.json so composer install works, but when it has to run composer's post install commands, you have nothing else, that is why you have to move EVERYTHING into the image, then install因为你在正在构建的图像上什么都没有,你只有composer.json所以composer install可以工作,但是当它必须运行 composer 的安装后命令时,你什么都没有,这就是为什么你必须将所有东西都移动到图像中,然后安装

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Google Cloud Platform 上托管的 Laravel MySQL 应用程序上出现 500 错误 - Getting 500 error on Laravel MySQL application hosted on Google Cloud Platform 错误4003:ssh无法登录我在google云平台创建的实例 - Error 4003: can't ssh login into the instance that I created in google cloud platform 不安装 composer 需要 google/cloud-firestore - not install composer require google/cloud-firestore 无法让 Google Cloud Platform 识别 JSON 服务帐户密钥文件。 错误:PyOpenSSL 不可用。 建议使用 JSON,但我使用的是 JSON 密钥 - Can't get Google Cloud Platform to recognize JSON service account key file. Error: PyOpenSSL is not available. Suggests JSON but I'm using a JSON key Google AI 平台无法写入 Cloud Storage - Google AI platform can't write to Cloud Storage 有旧版本的谷歌云平台工具:Docker - There are older versions of Google Cloud Platform tools: Docker 如何在Google Cloud Platform中安装Google AI Platform中的Spark依赖 - How to install Spark dependencies in Google AI Platform in Google Cloud Platform 如何将数据库(postgres)连接到谷歌云平台上的 Airflow composer? - How to Connect Database(postgres) to Airflow composer On Google Cloud Platform? Google Cloud Composer 服务器遇到临时错误,无法完成您的请求 - Google Cloud Composer The server encountered a temporary error and could not complete your request Google Cloud Composer 安装依赖项的时间过长 - Google Cloud Composer taking too long to install dependencies
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM