From 1f87b49c150112349d600bc58818c57452ba2a1d Mon Sep 17 00:00:00 2001 From: Neshura Date: Wed, 20 Dec 2023 07:19:28 +0000 Subject: [PATCH] Add Dockerfile again --- Dockerfile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b565c64 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,45 @@ +## INIT STEP +# Install dependencies only when needed +FROM node:18-alpine AS deps + +RUN apk add --no-cache libc6-compat +WORKDIR /app + +# Copy the files needed to install deps +COPY package.json yarn.lock ./ +RUN yarn install --frozen-lockfile + +## BUILD STEP +# Rebuild the source code only when needed +FROM node:18-alpine AS builder + +WORKDIR /app + +# Copy node_modules installed by the deps step +COPY --from=deps /app/node_modules ./node_modules + +COPY . . + +RUN yarn build + +## RUN STEP +FROM node:18-alpine AS runner + +LABEL author="neshura@proton.me" +WORKDIR /app + +ENV NODE_ENV production + +COPY --from=builder /app/public ./public +COPY --from=builder /app/node_modules ./node_modules + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static + +# expose port 3000 +ENV PORT 3000 +EXPOSE 3000 + +CMD [ "yarn", "start" ] \ No newline at end of file