understanding commited on
Commit
85e9869
·
verified ·
1 Parent(s): 7cc5dc9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -8
Dockerfile CHANGED
@@ -44,17 +44,22 @@ WORKDIR /app
44
  # Enable pnpm
45
  RUN corepack enable
46
 
47
- # Switch to the built-in, non-root 'node' user for security
 
 
 
 
 
 
 
48
  USER node
49
 
50
  # Copy over the essential files from the builder stage
51
- COPY --chown=node:node --from=builder /app/package.json ./package.json
52
- COPY --chown=node:node --from=builder /app/pnpm-lock.yaml* ./
53
- COPY --chown=node:node --from=builder /app/node_modules ./node_modules
54
- COPY --chown=node:node --from=builder /app/dist ./dist
55
-
56
- # Create a directory for session data
57
- RUN mkdir ./sessions
58
 
59
  # Set the command to run your application using the "start" script.
60
  CMD [ "pnpm", "start" ]
 
44
  # Enable pnpm
45
  RUN corepack enable
46
 
47
+ # Create the directory for session data AS THE ROOT USER
48
+ RUN mkdir ./sessions
49
+
50
+ # Change ownership of the entire app directory to the 'node' user.
51
+ # This must be done BEFORE switching to the node user.
52
+ RUN chown -R node:node /app
53
+
54
+ # NOW, switch to the built-in, non-root 'node' user for security
55
  USER node
56
 
57
  # Copy over the essential files from the builder stage
58
+ # These files will now be correctly owned by 'node' because of the chown command above.
59
+ COPY --from=builder /app/package.json ./package.json
60
+ COPY --from=builder /app/pnpm-lock.yaml* ./
61
+ COPY --from=builder /app/node_modules ./node_modules
62
+ COPY --from=builder /app/dist ./dist
 
 
63
 
64
  # Set the command to run your application using the "start" script.
65
  CMD [ "pnpm", "start" ]