本文 PHP 基础镜像使用:php:7.3-apache
本文 Laravel 版本为:laravel:5.8.*
队列和任务调度我们在下一篇写
一、 准备我们的 Laravel 应用
# 运行 mix 命令,打包 js、css、img 文件,如果没有用到 mix 这一步可以省略
npm install
npm run production
# 安装 composer.lock 中的依赖
composer install --ignore-platform-reqs --optimize-autoloader --no-dev二、 准备 Apache 配置文件 docker/000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com ServerAdmin liuzhaowei55@gmail.com
DocumentRoot /var/www/html/public
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
三、 准备 Dockerfile 文件
FROM php:7.3-apacheLABEL maintainer="liuzhaowei55@gmail.com"
# 设置时区
ARG TZ=Asia/Shanghai
ENV TZ ${TZ}
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 安装软件 cron
RUN set -eux
&& apt-get update
&& apt-get install -y --no-install-recommends cron
&& apt-get autoremove
&& apt-get autoclean
&& apt-get clean
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# 安装拓展
ENV PHP_EXTENSION
pdo_mysql
bcmath
ENV PECL_EXTENSION
redis
RUN docker-php-ext-install $PHP_EXTENSION
&& pecl install $PECL_EXTENSION
&& docker-php-ext-enable $PECL_EXTENSION
opcache
&& a2enmod rewrite
# 访问端口










