/ api-gateway / 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 fastapi; \ 8 else \ 9 echo "Using existing user with UID 1000"; \ 10 fi && \ 11 chown -R 1000:1000 /app 12 13 # Install dependencies 14 COPY requirements.txt . 15 RUN pip install --no-cache-dir -r requirements.txt 16 17 # Copy application 18 COPY . . 19 20 # Create uploads and sessions directories with proper permissions 21 RUN mkdir -p /app/uploads /app/sessions && \ 22 chown -R 1000:1000 /app/uploads /app/sessions && \ 23 chmod -R 755 /app/uploads /app/sessions 24 25 # Install util-linux for runuser (user switching) 26 RUN apt-get update && \ 27 apt-get install -y --no-install-recommends util-linux && \ 28 rm -rf /var/lib/apt/lists/* 29 30 # Copy entrypoint script and make it executable 31 COPY docker-entrypoint.sh /docker-entrypoint.sh 32 RUN chmod +x /docker-entrypoint.sh 33 34 EXPOSE 8000 35 36 # Entrypoint runs as root to fix permissions, then switches to user 1000 37 ENTRYPOINT ["/docker-entrypoint.sh"] 38 39 # Default command (entrypoint will switch to user 1000) 40 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]