Skip to content

Commit 7e0a8e5

Browse files
Fix: Docker file permissions for non-root user (#17)
Container tests were failing with 'Permission denied' errors when trying to read configuration files (.env, models.json) and application files. Root cause: Files were copied as root user before switching to 'node' user, resulting in the node user lacking read permissions. Solution: Added explicit ownership and permission setting before USER switch: - chown -R node:node /app - Set node as owner of all files - chmod -R u+rw,go+r /app - Grant read/write to user, read to others - chmod +x /app/src/server.js - Make server.js executable This ensures consistent behavior across different Docker versions and build environments. All 303 tests now passing.
1 parent 83df4ff commit 7e0a8e5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

docker/Dockerfile.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ COPY src/ ./src/
2121
COPY docker/.env ./.env
2222
COPY docker/models.json ./models.json
2323

24+
# Set correct ownership and permissions for node user
25+
RUN chown -R node:node /app && \
26+
chmod -R u+rw,go+r /app && \
27+
chmod +x /app/src/server.js
28+
2429
# Switch to non-root user for security
2530
USER node
2631

0 commit comments

Comments
 (0)