From 6f3f7d227dcce999a931192cc408ba33391e6157 Mon Sep 17 00:00:00 2001 From: jonastheis Date: Sun, 19 Apr 2020 17:27:15 +0000 Subject: [PATCH] Docker multistage build (#113) Frozen lockfile Adjust to mutlistage build Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/113 --- Dockerfile | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 99a276e8e8..44f7b729fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,16 @@ -FROM nginx +# Stage 1: Build application +FROM node:13.13.0 AS compile-image -MAINTAINER maintainers@vikunja.io +WORKDIR /build + +COPY . ./ + +RUN yarn install --frozen-lockfile +RUN yarn run build + + +# Stage 2: copy +FROM nginx RUN apt-get update && apt-get install -y apt-utils openssl && \ mkdir -p /etc/nginx/ssl && \ @@ -8,6 +18,9 @@ RUN apt-get update && apt-get install -y apt-utils openssl && \ openssl req -new -key /etc/nginx/ssl/dummy.key -out /etc/nginx/ssl/dummy.csr -subj "/C=DE/L=Berlin/O=Vikunja/CN=Vikunja Snakeoil" && \ openssl x509 -req -days 3650 -in /etc/nginx/ssl/dummy.csr -signkey /etc/nginx/ssl/dummy.key -out /etc/nginx/ssl/dummy.crt -ADD nginx.conf /etc/nginx/nginx.conf +COPY nginx.conf /etc/nginx/nginx.conf -COPY dist /usr/share/nginx/html \ No newline at end of file +# copy compiled files from stage 1 +COPY --from=compile-image /build/dist /usr/share/nginx/html + +LABEL maintainer="maintainers@vikunja.io" \ No newline at end of file