From 03e7e22d745b174d26ee04e6561bbb3b4da2f34c Mon Sep 17 00:00:00 2001 From: Divlo Date: Thu, 29 Sep 2022 19:07:20 +0200 Subject: [PATCH] chore: reduce docker image size --- Dockerfile | 18 ++++++++---------- docker-compose.yml | 4 ++-- next.config.js | 3 ++- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5f4ae08..3e339d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,21 @@ -FROM node:16.17.0 AS dependencies +FROM node:16.17.1 AS dependencies WORKDIR /usr/src/app COPY ./package*.json ./ RUN npm install -FROM node:16.17.0 AS builder +FROM node:16.17.1 AS builder WORKDIR /usr/src/app COPY ./ ./ COPY --from=dependencies /usr/src/app/node_modules ./node_modules RUN npm run build -FROM node:16.17.0 AS runner +FROM node:16.17.1 AS runner WORKDIR /usr/src/app ENV NODE_ENV=production -COPY --from=builder /usr/src/app/next.config.js ./next.config.js +ENV NEXT_TELEMETRY_DISABLED 1 +COPY --from=builder /usr/src/app/.next/standalone ./ +COPY --from=builder /usr/src/app/.next/static ./.next/static COPY --from=builder /usr/src/app/public ./public -COPY --from=builder /usr/src/app/.next ./.next -COPY --from=builder /usr/src/app/i18n.json ./i18n.json COPY --from=builder /usr/src/app/locales ./locales -COPY --from=builder /usr/src/app/pages ./pages -COPY --from=builder /usr/src/app/node_modules ./node_modules -RUN npx next telemetry disable -CMD ["node_modules/.bin/next", "start", "--port", "${PORT}"] +COPY --from=builder /usr/src/app/next.config.js ./next.config.js +CMD ["node", "server.js"] diff --git a/docker-compose.yml b/docker-compose.yml index aeb3acd..eea4024 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: build: context: './' ports: - - '${PORT}:${PORT}' + - '${PORT-3000}:${PORT-3000}' environment: - PORT: ${PORT} + PORT: ${PORT-3000} env_file: './.env' diff --git a/next.config.js b/next.config.js index 5f6140c..37462fc 100644 --- a/next.config.js +++ b/next.config.js @@ -7,6 +7,7 @@ const nextTranslate = require('next-translate') /** @type {import("next").NextConfig} */ module.exports = nextTranslate( nextPWA({ - reactStrictMode: true + reactStrictMode: true, + output: 'standalone' }) )