Skip to content

Instantly share code, notes, and snippets.

@curder
Last active August 27, 2019 03:19
Show Gist options
  • Save curder/b75ca1186e8f4a2c2a43526f9ebaaff1 to your computer and use it in GitHub Desktop.
Save curder/b75ca1186e8f4a2c2a43526f9ebaaff1 to your computer and use it in GitHub Desktop.
Laravel Multi Stage Demo.
#
# 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
@curder
Copy link
Author

curder commented Aug 27, 2019

下载 Laravel 项目

laravel new multi-stage-demo

将上面的 Dockerfile 放到项目根目录下。

提前拉取镜像

docker pull composer:1.9
docker pull node:10.16
docker pull php:7.2-apache-stretch

构建镜像

docker build -t curder/multi-stage-demo .

查看构建的镜像

docker images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment