implemented Dockerfile

This commit is contained in:
2024-01-09 16:55:46 +01:00
parent 102edff52f
commit 3abba9347b
2 changed files with 34 additions and 0 deletions

6
.dockerignore Normal file
View File

@@ -0,0 +1,6 @@
.dockerignore
.git
.vscode
.gitignore
node_modules
mongo

28
Dockerfile Normal file
View File

@@ -0,0 +1,28 @@
# Stage 1: Build the Next.js project
FROM node:18 AS builder
ENV WORKDIR=/app
WORKDIR /app
# copy all the soruce code
COPY . .
# installing dependencies
RUN npm i && npm cache clean --force
# building app
RUN npm run build
# Stage 2: Run the Next.js server
FROM gcr.io/distroless/nodejs:18 as prod-image
WORKDIR /app
COPY --from=builder /app/package.json /app/package-lock.json ./
# installing production dependencies
RUN npm i --verbose --only=production && npm cache clean --force
COPY --from=builder /app/.next ./.next
COPY ./public /app/public
CMD ["npm", "start"]