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:
@@ -0,0 +1,41 @@
|
||||
FROM node:20-alpine
|
||||
|
||||
# Install MinIO client
|
||||
RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc && \
|
||||
chmod +x mc && \
|
||||
mv mc /usr/local/bin/
|
||||
|
||||
# Install development dependencies
|
||||
RUN apk add --no-cache bash
|
||||
|
||||
# Create app directory
|
||||
WORKDIR /app
|
||||
|
||||
# Create non-root user (same UID/GID as most development systems)
|
||||
RUN addgroup -g 1000 -S nodejs && \
|
||||
adduser -S nodejs -u 1000 -G nodejs
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies as root
|
||||
RUN npm install
|
||||
|
||||
# Create necessary directories
|
||||
RUN mkdir -p logs temp && \
|
||||
chmod 755 logs temp
|
||||
|
||||
# Copy application files
|
||||
COPY . .
|
||||
|
||||
# Change ownership of everything to nodejs user
|
||||
RUN chown -R nodejs:nodejs /app
|
||||
|
||||
# Switch to non-root user
|
||||
USER nodejs
|
||||
|
||||
# Expose port
|
||||
EXPOSE 7510
|
||||
|
||||
# Start the application in development mode
|
||||
CMD ["npm", "run", "dev"]
|
||||
Reference in New Issue
Block a user