implemented Dockerfile
This commit is contained in:
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.dockerignore
|
||||||
|
.git
|
||||||
|
.vscode
|
||||||
|
.gitignore
|
||||||
|
node_modules
|
||||||
|
mongo
|
||||||
28
Dockerfile
Normal file
28
Dockerfile
Normal 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"]
|
||||||
Reference in New Issue
Block a user