实战多阶段构建 Laravel 镜像
准备
.idea/
.git/
vendor/
node_modules/
public/js/
public/css/
yarn-error.log
bootstrap/cache/*
storage/
# 自行添加其他需要排除的文件,例如 .env.* 文件server {
listen 80 default_server;
root /app/laravel/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ .*\.php(\/.*)*$ {
fastcgi_pass laravel:9000;
include fastcgi.conf;
# fastcgi_connect_timeout 300;
# fastcgi_send_timeout 300;
# fastcgi_read_timeout 300;
}
}前端构建
安装 Composer 依赖
整合以上阶段所生成的文件
最后一个阶段构建 NGINX 镜像
构建 Laravel 及 Nginx 镜像
启动容器并测试
生产环境优化
附录
Last updated