File tree Expand file tree Collapse file tree
06-building-container-images/api-node Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Pin specific version for stability
22# Use alpine for reduced image size
3- FROM node:19.6-alpine AS base
3+ FROM node:19.6-alpine
4+
5+ # Set NODE_ENV
6+ ENV NODE_ENV production
47
58# Specify working directory other than /
69WORKDIR /usr/src/app
@@ -9,21 +12,6 @@ WORKDIR /usr/src/app
912# dependencies (better layer caching)
1013COPY package*.json ./
1114
12- FROM base as dev
13-
14- RUN --mount=type=cache,target=/usr/src/app/.npm \
15- npm set cache /usr/src/app/.npm && \
16- npm install
17-
18- COPY . .
19-
20- CMD ["npm", "run", "dev"]
21-
22- FROM base as production
23-
24- # Set NODE_ENV
25- ENV NODE_ENV production
26-
2715# Install only production dependencies
2816# Use cache mount to speed up install of existing dependencies
2917RUN --mount=type=cache,target=/usr/src/app/.npm \
@@ -44,4 +32,4 @@ COPY --chown=node:node ./src/ .
4432# Indicate expected port
4533EXPOSE 3000
4634
47- CMD [ "node", "index.js" ]
35+ CMD [ "node", "index.js" ]
You can’t perform that action at this time.
0 commit comments