fix: Resolve Docker permission issues in development environment

- Create dedicated Dockerfile.backend.dev for development with proper permissions
- Set user UID/GID to 1000 (common for development systems)
- Create logs and temp directories in Dockerfile before switching user
- Use named volumes for logs, temp, and node_modules to maintain permissions
- Mount only source files instead of entire backend directory
- Remove complex entrypoint script in favor of simple CMD
- Add LOG_DIR and TEMP_DIR environment variables

This fixes the "Permission denied" errors when creating directories in Docker.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-07-23 14:32:14 +02:00
parent d99a299bf5
commit 7bcee648ad
4 changed files with 61 additions and 24 deletions
+4 -8
View File
@@ -21,14 +21,10 @@ COPY . .
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001
# Create logs directory with proper permissions
RUN mkdir -p logs && \
# Create necessary directories with proper permissions
RUN mkdir -p logs temp && \
chown -R nodejs:nodejs /app && \
chmod 755 logs
# Copy and set permissions for entrypoint
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
chmod 755 logs temp
# Switch to non-root user
USER nodejs
@@ -37,4 +33,4 @@ USER nodejs
EXPOSE 3000
# Start the application
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["node", "src/app.js"]