server { listen 80default_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; }}
前端构建
第一阶段进行前端构建。
FROM node:alpine as frontendCOPY package.json /app/RUN set -x ; cd /app \ && npm install --registry=https://registry.npmmirror.comCOPY webpack.mix.js webpack.config.js tailwind.config.js /app/COPY resources/ /app/resources/RUN set -x ; cd /app \ && touch artisan \ && mkdir -p public \ && npm run production
安装 Composer 依赖
第二阶段安装 Composer 依赖。
FROM composer as composerCOPY database/ /app/database/COPY composer.json composer.lock /app/RUN set -x ; cd /app \ && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \ && composer install \ --ignore-platform-reqs \ --no-interaction \ --no-plugins \ --no-scripts \ --prefer-dist
FROM nginx:alpine as nginxARG LARAVEL_PATH=/app/laravelCOPY laravel.conf /etc/nginx/conf.d/COPY --from=laravel ${LARAVEL_PATH}/public ${LARAVEL_PATH}/public