-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
39 lines (33 loc) · 959 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
# base node image
FROM node:hydrogen-bullseye-slim as base
RUN npm install -g pnpm is-ci husky
# Install all node_modules, including dev dependencies
FROM base as deps
ENV CI=true
WORKDIR /myapp
ADD package.json pnpm-lock.yaml .npmrc ./
RUN pnpm install
# Setup production node_modules
FROM base as production-deps
ENV NODE_ENV production
WORKDIR /myapp
ADD package.json pnpm-lock.yaml .npmrc ./
RUN pnpm prune --prod
# Build the app
FROM base as build
ENV CI=true
ENV NODE_ENV production
WORKDIR /myapp
COPY --from=deps /myapp/node_modules /myapp/node_modules
ADD . .
RUN pnpm build
# Finally, build the production image with minimal footprint
FROM base
ENV PORT 8080
ENV NODE_ENV production
WORKDIR /myapp
COPY --from=production-deps /myapp/node_modules /myapp/node_modules
COPY --from=build /myapp/build /myapp/build
COPY --from=build /myapp/public /myapp/public
COPY --from=build /myapp/package.json /myapp/package.json
CMD ["npm", "run", "start"]