-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
37 lines (26 loc) Β· 839 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# STAGE-1: CONFIGURING DOCKER IMAGE
FROM node:18-alpine AS builder
WORKDIR /app
# COPYING package.json & package-lock.json (IF EXISTS) FOR DPENDANCY INSTALLATION
COPY package*.json ./
# INSTALLING DEPENDENCIES
RUN npm install
# COPING REST ESSENTIALS OF THIS APP
COPY . .
# PRODUCTION BUILD FOR THIS APP
RUN npm run build
# STAGE-2: FINAL DOCKER IMAGE BUILDS FOR THIS APP
FROM node:18-alpine AS runner
WORKDIR /app
# COPY ESSENTIALS FROM BUILDER'S STAGE
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/node_modules ./node_modules
# PORT EXPOSING FOR APP ACCESS
EXPOSE 3000
# SETTING ENVIRONMENT VARIABLE FOR PRODUCTION
ENV NODE_ENV production
ENV PORT 3000
# RUN THIS APP IN PRODUCTION MODE
CMD ["npm", "start:prod"]