mirror of
https://github.com/MrUnknownDE/unknownbin.git
synced 2026-04-10 10:13:45 +02:00
Correct file permissions for non-root user in Docker
This commit is contained in:
@@ -32,15 +32,22 @@ FROM base AS production
|
||||
|
||||
# Set a non-root user for security
|
||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||
USER appuser
|
||||
|
||||
# Copy only the necessary files from the previous stages
|
||||
COPY --from=build /usr/src/app/node_modules ./node_modules
|
||||
COPY --from=build /usr/src/app/views ./views
|
||||
COPY --from=build /usr/src/app/static ./static
|
||||
COPY --from=build /usr/src/app/lib ./lib
|
||||
COPY --from=build /usr/src/app/server.js .
|
||||
COPY --from=build /usr/src/app/config.json .
|
||||
|
||||
# Create the data directory and set correct permissions
|
||||
# This is the FIX for the EACCES error
|
||||
RUN mkdir -p data && chown -R appuser:appgroup .
|
||||
|
||||
# Switch to the non-root user
|
||||
USER appuser
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 8080
|
||||
|
||||
|
||||
Reference in New Issue
Block a user