/ worker / Dockerfile
Dockerfile
 1  FROM python:3.12-slim
 2  
 3  WORKDIR /app
 4  
 5  # Create non-root user (UID 1000) or use existing if it exists
 6  RUN if ! getent passwd 1000 > /dev/null 2>&1; then \
 7          useradd -m -u 1000 worker; \
 8      else \
 9          echo "Using existing user with UID 1000"; \
10      fi && \
11      chown -R 1000:1000 /app
12  
13  # Install dependencies (skip if empty)
14  COPY requirements.txt .
15  RUN if [ -s requirements.txt ]; then pip install --no-cache-dir -r requirements.txt; fi
16  
17  # Copy application
18  COPY . .
19  
20  # Switch to non-root user
21  USER 1000
22  
23  CMD ["python", "worker.py"]