-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrontend.Dockerfile
48 lines (33 loc) · 981 Bytes
/
frontend.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
38
39
40
41
42
43
44
45
46
47
48
# FROM node:22-alpine
# # ENV NODE_ENV=production
# ENV PORT=3000
# ENV NEXT_TELEMETRY_DISABLED=1
# ENV BACKEND_URL='http://backend:5000'
# WORKDIR /app
# COPY ./frontend/ ./
# RUN npm install
# RUN npm run build
# # CMD ["sh", "-c", "sleep 20 && npm run build && npm run start -- -p ${PORT}"]
# CMD ["sh", "-c", "npm run start -- -p ${PORT}"]
# multistage dockerfile:
# stage 1: builder
FROM node:22-alpine AS builder
ENV BACKEND_URL='http://backend:5000'
WORKDIR /app
COPY ./frontend/ ./
RUN npm install
RUN npm run build
# stage 2: runner
FROM node:22-alpine AS runner
ENV NODE_ENV='production'
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV BACKEND_URL='http://backend:5000'
WORKDIR /app
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./
COPY --from=builder /app/node_modules ./node_modules
# RUN npm install --omit=dev
RUN npm prune --production
CMD ["npm", "run", "start", "-- -p $PORT"]