-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
48 lines (30 loc) · 967 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
38
39
40
41
42
43
44
45
46
47
48
# base node image
FROM node:18-bullseye-slim as base
# set for base and all layer that inherit from it
ENV NODE_ENV=production
# Install all node_modules, including dev dependencies
FROM base as deps
WORKDIR /app
COPY package.json package-lock.json .npmrc ./
RUN npm install --include=dev
# Setup production node_modules
FROM base as production-deps
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
COPY package.json package-lock.json .npmrc ./
RUN npm prune --omit=dev
# Build the app
FROM base as build
ARG CLOUDINARY_URL
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
COPY . .
RUN CLOUDINRAY_URL=${CLOUDINRAY_URL} npm run build
# Finally, build the production image with minimal footprint
FROM base
WORKDIR /app
COPY --from=production-deps /app/node_modules /app/node_modules
COPY --from=build /app/build /app/build
COPY --from=build /app/package.json /app/package.json
EXPOSE 3000
CMD ["npm", "run", "start"]