From 2c6dbb42c1edebde9dbfd5b01967a6e0bc6f942e Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 3 Mar 2019 10:12:59 +0100 Subject: [PATCH] Simplified Dockerfile using multi-stage build --- .dockerignore | 1 + Dockerfile | 25 ++++++------------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/.dockerignore b/.dockerignore index 74976a73..1019f996 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,5 @@ ./build +./coverage ./dist ./node_modules ./test diff --git a/Dockerfile b/Dockerfile index 343b1217..05c1d33a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,8 @@ +FROM node:10.15.2 as node +COPY . /shlink-web-client +RUN cd /shlink-web-client && yarn install && yarn build + FROM nginx:1.15.9-alpine LABEL maintainer="Alejandro Celaya " - -# Install node and yarn -RUN apk add --no-cache nodejs && apk add --no-cache yarn - -ADD . ./shlink-web-client - -# Install dependencies and build project -RUN cd ./shlink-web-client && \ - yarn install && \ - yarn build && \ - - # Move build contents to document root - cd .. && \ - rm -r /usr/share/nginx/html/* && \ - mv ./shlink-web-client/build/* /usr/share/nginx/html && \ - rm -r ./shlink-web-client && \ - - # Delete and uninstall build tools - yarn cache clean && apk del yarn && apk del nodejs +RUN rm -r /usr/share/nginx/html +COPY --from=node /shlink-web-client/build /usr/share/nginx/html