From b576f0734f8ed2e8fe6ca1d0551bb512d4044d8f Mon Sep 17 00:00:00 2001 From: TheCatLady <52870424+TheCatLady@users.noreply.github.com> Date: Tue, 2 Feb 2021 19:52:56 -0500 Subject: [PATCH] build(docker): Optimize Docker image layers/caching & bump node to 14.15 (#776) * refactor(docker): Combine RUN statements to reduce number of image layers * Add --update && --no-cache to apk add command * Combine RUN statements in first stage * Consolidate COPY commands from BUILD_IMAGE * Add docs & snap to .dockerignore * Revert first COPY statement in 2nd stage * Write committag.json in first stage & only do one COPY Also pin base image Alpine version, and add Docker & GitHub Actions update monitoring via Dependabot * Bump node to 14.15.4 * Change base image to node:14.15-alpine and remove Dependabot Docker monitoring * Changes in response to PR comments * Remove ARG/ENV statements from second build stage --- .dockerignore | 24 ++++++++++++++++-------- .github/dependabot.yml | 6 ++++++ Dockerfile | 22 +++++++++------------- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/.dockerignore b/.dockerignore index 4d49270e..4095dce5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,15 +1,23 @@ -node_modules -.next +**/*.md +**/.gitkeep +**/.vscode +.all-contributorsrc +.dockerignore +.editorconfig +.eslintrc.js .git +.gitbook.yaml .gitconfig .gitignore .github -.all-contributorsrc -.editorconfig +.next .prettierignore -**/README.md -**/.vscode config/db/db.sqlite3 config/db/logs/overseerr.log -Dockerfil** -**.md +Dockerfile* +docker-compose.yml +docs +LICENSE +node_modules +snap +stylelint.config.js diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c4d690b7..7590f941 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,3 +6,9 @@ updates: interval: daily time: '20:00' open-pull-requests-limit: 10 + - package-ecosystem: github-actions + directory: '/' + schedule: + interval: daily + time: '20:00' + open-pull-requests-limit: 10 diff --git a/Dockerfile b/Dockerfile index 8a0190bf..8b196341 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:12.18-alpine AS BUILD_IMAGE +FROM node:14.15-alpine AS BUILD_IMAGE ARG COMMIT_TAG ENV COMMIT_TAG=${COMMIT_TAG} @@ -11,24 +11,20 @@ RUN yarn --frozen-lockfile && \ # remove development dependencies RUN yarn install --production --ignore-scripts --prefer-offline -RUN yarn cache clean -FROM node:12.18-alpine +RUN rm -rf src && \ + rm -rf server -ARG COMMIT_TAG -ENV COMMIT_TAG=${COMMIT_TAG} +RUN echo "{\"commitTag\": \"${COMMIT_TAG}\"}" > committag.json -RUN apk add tzdata -COPY . /app -WORKDIR /app +FROM node:14.15-alpine -# copy from build image -COPY --from=BUILD_IMAGE /app/dist ./dist -COPY --from=BUILD_IMAGE /app/.next ./.next -COPY --from=BUILD_IMAGE /app/node_modules ./node_modules +RUN apk add --no-cache tzdata -RUN echo "{\"commitTag\": \"${COMMIT_TAG}\"}" > committag.json +# copy from build image +COPY --from=BUILD_IMAGE /app /app +WORKDIR /app CMD yarn start