Last active
August 27, 2019 03:19
-
-
Save curder/b75ca1186e8f4a2c2a43526f9ebaaff1 to your computer and use it in GitHub Desktop.
Laravel Multi Stage Demo.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# PHP Dependencies | |
# | |
FROM composer:1.9 as vendor | |
COPY database/ database/ | |
COPY composer.json composer.json | |
COPY composer.lock composer.lock | |
RUN composer config -g repos.packagist composer "https://mirrors.aliyun.com/composer" && composer install \ | |
--ignore-platform-reqs \ | |
--no-interaction \ | |
--no-plugins \ | |
--no-scripts \ | |
--prefer-dist \ | |
--no-dev | |
# | |
# Frontend | |
# | |
FROM node:10.16 as frontend | |
RUN mkdir -p /app/public | |
COPY package.json webpack.mix.js yarn.lock /app/ | |
COPY resources/js/ /app/resources/js/ | |
COPY resources/sass/ /app/resources/sass/ | |
WORKDIR /app | |
RUN yarn install && yarn production | |
# | |
# Application | |
# | |
FROM php:7.2-apache-stretch | |
COPY . /var/www/html | |
COPY --from=vendor /app/vendor/ /var/www/html/vendor/ | |
COPY --from=frontend /app/public/js/ /var/www/html/public/js/ | |
COPY --from=frontend /app/public/css/ /var/www/html/public/css/ | |
COPY --from=frontend /app/mix-manifest.json /var/www/html/mix-manifest.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
下载 Laravel 项目
将上面的
Dockerfile
放到项目根目录下。提前拉取镜像
构建镜像
查看构建的镜像