From 92da0a444d953d2e51f06f5297f1a85a8ee8a254 Mon Sep 17 00:00:00 2001 From: Adam Stachowicz Date: Thu, 29 Jul 2021 01:38:45 +0200 Subject: [PATCH] Reduce Docker size --- .dockerignore | 25 +++++++++++++++++++++++-- dockerfile | 17 +++++++++++++++-- vite.config.js | 20 ++++++++++---------- 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/.dockerignore b/.dockerignore index 825d58038..4ddce98b0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,14 +1,35 @@ /.idea /dist /node_modules -/data/kuma.db +/data /.do **/.dockerignore **/.git **/.gitignore **/docker-compose* -**/Dockerfile* +**/[Dd]ockerfile* LICENSE README.md .editorconfig .vscode +.eslint* +.stylelint* +/.github +package-lock.json +yarn.lock +app.json + +### .gitignore content (commented rules are duplicated) + +#node_modules +.DS_Store +#dist +dist-ssr +*.local +#.idea + +#/data +#!/data/.gitkeep +#.vscode + +### End of .gitignore content diff --git a/dockerfile b/dockerfile index 1ebf00999..ee05d0b20 100644 --- a/dockerfile +++ b/dockerfile @@ -1,5 +1,5 @@ # DON'T UPDATE TO alpine3.13, 1.14, see #41. -FROM node:14-alpine3.12 AS release +FROM node:14-alpine3.12 AS release-base WORKDIR /app # split the sqlite install here, so that it can caches the arm prebuilt @@ -28,14 +28,27 @@ RUN apprise --version # New things add here +FROM release-base AS build + COPY . . RUN npm install RUN npm run build +FROM release-base AS release-final + EXPOSE 3001 VOLUME ["/app/data"] HEALTHCHECK --interval=60s --timeout=30s --start-period=300s CMD node extra/healthcheck.js + +COPY --from=build /app/package.json package.json +RUN npm install --only=prod +RUN rm package-lock.json + +COPY --from=build /app/extra /app/extra +COPY --from=build /app/server /app/server +COPY --from=build /app/dist /app/dist + CMD ["npm", "run", "start-server"] -FROM release AS nightly +FROM release-final AS nightly RUN npm run mark-as-nightly diff --git a/vite.config.js b/vite.config.js index f93fb0269..68754da8e 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,14 +1,14 @@ -import { defineConfig } from 'vite' -import vue from '@vitejs/plugin-vue' -import legacy from '@vitejs/plugin-legacy' +import legacy from "@vitejs/plugin-legacy" +import vue from "@vitejs/plugin-vue" +import { defineConfig } from "vite" // https://vitejs.dev/config/ export default defineConfig({ - plugins: [ - vue(), - legacy({ - targets: ['ie > 11'], - additionalLegacyPolyfills: ['regenerator-runtime/runtime'] - }) - ] + plugins: [ + vue(), + legacy({ + targets: ["ie > 11"], + additionalLegacyPolyfills: ["regenerator-runtime/runtime"], + }), + ], })