File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,11 +29,21 @@ COPY --from=builder /app/.output ./.output
2929COPY --from=builder /app/node_modules ./node_modules
3030COPY --from=builder /app/public ./public
3131
32+ # Create non-root user for security
33+ RUN addgroup -g 1001 -S app
34+ RUN adduser -S app -u 1001 -G app
35+
36+ # Change ownership of the app directory to the non-root user
37+ RUN chown -R app:app /app
38+
3239ENV NUXT_HOST=0.0.0.0
3340ENV NUXT_PORT=3000
3441
3542# Expose port 3000
3643EXPOSE 3000
3744
45+ # Switch to non-root user
46+ USER app
47+
3848# Start the web app
3949CMD ["npm" , "start" ]
Original file line number Diff line number Diff line change @@ -31,12 +31,22 @@ RUN npm ci --omit=dev
3131# Copy build directory from stage 1
3232COPY --from=build /app/dist .
3333
34+ # Create non-root user for security
35+ RUN addgroup -g 1001 -S app
36+ RUN adduser -S app -u 1001 -G app
37+
38+ # Change ownership of the app directory to the non-root user
39+ RUN chown -R app:app /app
40+
3441# Setup ENV variable
3542ENV NODE_ENV=production
3643ENV PORT=80
3744
3845# Expose port 80 to allow incoming traffic
3946EXPOSE 80
4047
48+ # Switch to non-root user
49+ USER app
50+
4151# Start the Node web server
4252CMD ["node" , "index.js" ]
You can’t perform that action at this time.
0 commit comments