From 2b03e21f3def4cf6f0ecef79d8bedd4d801b9f45 Mon Sep 17 00:00:00 2001 From: MichiK <6341204+der-michik@users.noreply.github.com> Date: Tue, 4 Dec 2018 02:27:10 +0100 Subject: [PATCH] Improve Docker build caching First install the dependencies, then copy the files from the build context into the image. This allows for more caching during rebuilds when files change and rebuilds are much faster. --- contrib/Dockerfile | 6 +++--- contrib/nginx/Dockerfile | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/Dockerfile b/contrib/Dockerfile index 64158104..71bd0aa5 100644 --- a/contrib/Dockerfile +++ b/contrib/Dockerfile @@ -35,10 +35,10 @@ RUN rm -f /app/import/* /app/config/config.php # Build the PHP container FROM php:7-fpm-alpine WORKDIR /var/www -COPY --from=data /app/ /var/www RUN apk add --no-cache icu-dev gettext-dev && \ - docker-php-ext-install intl gettext pdo_mysql && \ - chown -R www-data:www-data /var/www/import/ /var/www/storage/ && \ + docker-php-ext-install intl gettext pdo_mysql +COPY --from=data /app/ /var/www +RUN chown -R www-data:www-data /var/www/import/ /var/www/storage/ && \ rm -r /var/www/html ENV TRUSTED_PROXIES 10.0.0.0/8,::ffff:10.0.0.0/8,\ diff --git a/contrib/nginx/Dockerfile b/contrib/nginx/Dockerfile index e838d368..609792c0 100644 --- a/contrib/nginx/Dockerfile +++ b/contrib/nginx/Dockerfile @@ -1,8 +1,8 @@ FROM node:8-alpine as themes WORKDIR /app +RUN apk add --no-cache yarn COPY resources/assets/ /app/resources/assets COPY .babelrc package.json webpack.config.js /app/ -RUN apk add --no-cache yarn RUN yarn install RUN yarn build