在项目的初始阶段,我想将Laravel应用程序部署到heroku上进行暂存环境。这分别是Dockerfile
和docker-compose
的配置。
Dockerfile
:
FROM php:7.2 AS base
RUN apt-get update -y && \
apt-get install -y openssl zip unzip git gnupg2
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
apt-get install -y nodejs
RUN curl -sS https://getcomposer.org/installer | \
php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install mbstring pdo pdo_mysql
WORKDIR /app
COPY . /app
FROM base AS dev
RUN apt-get update && apt-get install -y zlib1g-dev
RUN docker-php-ext-install zip
RUN composer install --prefer-dist
RUN npm install && npm run dev
docker-compose.yml
:
version: '3.4'
services:
app:
build:
context: .
dockerfile: Dockerfile
target: dev
command: php artisan serve --host=0.0.0.0 --port=8080
env_file:
- ./etc/env/.env.dev
working_dir: /app
volumes:
- ./:/app
ports:
- 8080:8080
使用docker-compose up -d
我想尝试将此设置部署到Heroku using the heroku.yml。
这是heroku.yml
设置。
build:
docker:
web: Dockerfile
run:
web: php artisan serve --host=0.0.0.0 --port=$PORT
那之后我执行
heroku container:push web
heroku container:release web
命令返回正确。但是当我使用heroku open
打开时显示错误。这是来自heroku logs --tail
的错误日志。
019-02-28T02:18:59.349362+00:00 app[api]: Deployed web (9552e86dc96a) by user *******@****.***
2019-02-28T02:18:59.349362+00:00 app[api]: Release v16 created by user *******@****.***
2019-02-28T02:19:23.326195+00:00 heroku[web.1]: Starting process with command `php -a`
2019-02-28T02:19:25.764530+00:00 heroku[web.1]: State changed from starting to crashed
2019-02-28T02:19:25.744534+00:00 heroku[web.1]: Process exited with status 0
2019-02-28T02:19:25.667622+00:00 app[web.1]: Interactive shell
2019-02-28T02:19:25.667644+00:00 app[web.1]:
2019-02-28T02:19:26.615159+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=***************.herokuapp.com request_id=f81366af-be1e-4a92-a14a-5c726bf163d9 fwd="203.210.84.30" dyno= connect= service= status=503 bytes= protocol=https
我做错了什么?