Skip to content

Instantly share code, notes, and snippets.

@paulredmond
Created November 26, 2019 17:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulredmond/06d9d08c3999236c66e89c2f7b3e5230 to your computer and use it in GitHub Desktop.
Save paulredmond/06d9d08c3999236c66e89c2f7b3e5230 to your computer and use it in GitHub Desktop.
Example of a Laravel multi-stage build
FROM composer:1.7 as vendor
COPY database/ database/
COPY composer.json composer.json
COPY composer.lock composer.lock
RUN composer install \
--ignore-platform-reqs \
--no-interaction \
--no-plugins \
--no-scripts \
--prefer-dist
#
# Frontend
#
FROM node:8.11 as frontend
RUN mkdir -p /app/public
COPY package.json webpack.mix.js yarn.lock /app/
COPY resources/assets/ /app/resources/assets/
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