From bc772f641a7b5cc2b437cde2c1f64c565fdc61e9 Mon Sep 17 00:00:00 2001 From: Trevor Sharp Date: Sat, 4 Jan 2025 18:33:42 +0000 Subject: [PATCH] Improve docker container --- Dockerfile | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index d92b686..dae2195 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,28 @@ -FROM node:lts - +FROM node:lts-alpine AS base WORKDIR /app COPY ./package.json ./package.json -RUN npm install + +# Install production dependencies +FROM base AS install + +RUN npm install --omit=dev + +# Build project +FROM install AS build ENV SKIP_ENV_VALIDATION=true +RUN npm install + COPY . . RUN npm run build -CMD ["npm", "run", "start"] +# Compose release container +FROM base AS release + +COPY --from=install /app/node_modules ./node_modules +COPY --from=build /app/.next ./.next + +EXPOSE 3000 +CMD ["npm", "run", "start"] \ No newline at end of file