-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
49 lines (31 loc) · 1.03 KB
/
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
49
# Use Node.js 20 as the base image
FROM node:20-slim as base
# Set for base and all layers that inherit from it
ENV NODE_ENV production
# Install all node_modules, including dev dependencies
FROM base as deps
RUN apt-get update && apt-get install -y build-essential python3
WORKDIR /jvelo
ADD package.json yarn.lock ./
RUN yarn install --production=false
# Setup production node_modules
FROM base as production-deps
WORKDIR /jvelo
COPY --from=deps /jvelo/node_modules /jvelo/node_modules
ADD package.json yarn.lock ./
RUN yarn install --production
# Build the app
FROM base as build
WORKDIR /jvelo
COPY --from=deps /jvelo/node_modules /jvelo/node_modules
ADD . .
RUN yarn run build
# Finally, build the production image with minimal footprint
FROM base
ENV NODE_ENV="production"
WORKDIR /jvelo
COPY --from=production-deps /jvelo/node_modules /jvelo/node_modules
COPY --from=build /jvelo/.next /jvelo/.next
COPY --from=build /jvelo/public /jvelo/public
COPY --from=build /jvelo/package.json /jvelo/package.json
ENTRYPOINT [ "yarn", "start" ]