服务器
本文 php 基础镜像使用:php:7.3-apache
本文 laravel 版本为:laravel:5.8.*
队列和任务调度我们在下一篇写
一、 准备我们的 laravel 应用
# 运行 mix 命令,打包 js、css、img 文件,如果没有用到 mix 这一步可以省略npm installnpm 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/shanghaienv tz ${tz}run ln -snf /usr/share/zoneinfo/$tz /etc/localtime && echo $tz > /etc/timezone# 安装软件 cronrun 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 \\\\ bcmathenv pecl_extension \\\\ redisrun docker-php-ext-install $php_extension \\\\ && pecl install $pecl_extension \\\\ && docker-php-ext-enable $pecl_extension \\\\ opcache \\\\ && a2enmod rewrite # 访问端口expose 80arg app_env=developmentenv app_env ${app_env}copy --chown=www-data:www-data . /var/www/htmlcopy docker/000-default.conf /etc/apache2/sites-available/000-default.confworkdir /var/www/html四、准备 dockerignore 文件:.dockerignore(非必需)
/node_modules/.dockerignore/dockerfile五、准备镜像入口文件:docker-entrypoint.sh(非必需)
注意一下,此文件需要执行权限,不过此入口文件不是必须的,只是为了在应用运行前执行一些缓存命令,具体可以点这里去文档了解一下。
#!/usr/bin/env bashphp artisan cache:clearphp artisan config:cachephp artisan route:cachephp artisan view:cacheapache2-foreground六、运行镜像
docker run -p 80:80 .以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持西部数码。
需要放置备案号-虚拟主机/数据库问题以智能城市为起点,百度智能云加速产业智能化进程部署了下重新解析了域名网址进不去麻烦给看下Linux中tail命令用法详解做一个公司网站域名多少钱常用的企业邮箱有哪些站群域名注册阿里云服务器不买域名能用吗吗知乎