From f8e78d1cc8bef15511ba8dfa242aa50165c76ed8 Mon Sep 17 00:00:00 2001 From: Mic Szillat Date: Fri, 12 Jan 2024 18:42:27 +0100 Subject: [PATCH 1/3] :recycle: Optimize Dockerfile - add all non-essential files to .dockerignore - improve cachability by layers - re-order lines to reduce layer generation --- .dockerignore | 9 +++++++++ Dockerfile | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index 85dcc16..f4d7d21 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,11 @@ +.browserslistrc +.dockerignore +.drone.yml +.editorconfig .git +.gitignore +.reuse +Dockerfile +LICENSES +README.md node_modules diff --git a/Dockerfile b/Dockerfile index 504781d..c3f8113 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,17 +4,25 @@ FROM node:14-alpine as builder -COPY . ./ +COPY package.json package-lock.json . +RUN npm install + +COPY .eslintrc.js . +COPY babel.config.js . +COPY public public +COPY src src RUN npm ci && npm run build FROM nginx as ki-frontend -COPY --from=builder /dist/ /usr/share/nginx/html/ -COPY etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf - LABEL org.opencontainers.image.source=https://git.wtf-eg.de/kompetenzinventar/ki-frontend.git LABEL org.opencontainers.image.url=https://git.wtf-eg.de/kompetenzinventar/ki-frontend LABEL org.opencontainers.image.documentation=https://git.wtf-eg.de/kompetenzinventar/ki-frontend#docker LABEL org.opencontainers.image.vendor="WTF Kooperative eG" + +WORKDIR /usr/share/nginx/html + +COPY etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf +COPY --from=builder /dist . From 7433d25716e53950e4cf6bf3c1eda7c7664fcd27 Mon Sep 17 00:00:00 2001 From: Brain Date: Tue, 23 Apr 2024 22:47:54 +0200 Subject: [PATCH 2/3] Add missing trailing slash --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c3f8113..c4d0188 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM node:14-alpine as builder -COPY package.json package-lock.json . +COPY package.json package-lock.json ./ RUN npm install COPY .eslintrc.js . From 81dcf5ebe728dd2f3216be17f8165382bbd62ad2 Mon Sep 17 00:00:00 2001 From: Brain Date: Tue, 23 Apr 2024 22:48:01 +0200 Subject: [PATCH 3/3] Try to build Docker image for Pull Requests --- .drone.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.drone.yml b/.drone.yml index c008511..675de0b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,6 +21,13 @@ steps: commands: - npm ci - npm run lint + - name: docker-build + image: plugins/docker + settings: + registry: git.wtf-eg.de + repo: git.wtf-eg.de/kompetenzinventar/frontend + target: ki-frontend + dry_run: true --- kind: pipeline