File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change 1
1
# ################### DEVELOPMENT STAGE ####################
2
- # Base image
3
2
FROM --platform=linux/amd64 node:20.13.1-alpine AS development
4
3
5
4
# Create app directory
@@ -8,25 +7,23 @@ WORKDIR /usr/src/app
8
7
# Create non-root user for better security
9
8
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
10
9
11
- # A wildcard is used to ensure both package.json AND package-lock.json are copied
10
+ # Copy all necessary files as root
12
11
COPY package*.json ./
13
-
14
- # Install app dependencies
15
- RUN npm i --ignore-scripts
16
-
17
- # Bundle app source
18
12
COPY src ./src
19
13
COPY tsconfig*.json ./
20
14
COPY nest-cli.json ./
21
- COPY package*.json ./
22
15
COPY eslint.config.mjs ./
23
16
24
- # Creates a "dist" folder with the production build
25
- RUN npm run build
17
+ # Install dependencies, build the app, and fix permissions in one step
18
+ RUN npm install --ignore-scripts \
19
+ && npm run build \
20
+ && chown -R appuser:appgroup /usr/src/app
21
+
22
+ # Switch to non-root user
23
+ USER appuser
26
24
27
25
# Expose the port on which the app will run
28
26
EXPOSE 3000
29
27
30
28
# Start the server using the production build
31
- CMD ["npm" , "run" , "start" ]
32
-
29
+ CMD ["npm" , "run" , "start" ]
You can’t perform that action at this time.
0 commit comments