Multi-stage backend Dockerfile (development/production), DB_* env vars, dev target pinning

This commit is contained in:
B0rbor4d
2026-07-31 23:47:29 +00:00
parent cf7c29639c
commit b91dd66fee
3 changed files with 14 additions and 3 deletions
+3
View File
@@ -21,6 +21,9 @@ DATABASE_URL=sqlite+aiosqlite:///./data/app.db
# Production: PostgreSQL (uncomment and configure) # Production: PostgreSQL (uncomment and configure)
# DATABASE_URL=postgresql+asyncpg://updater:secure-password@db:5432/insight_updater # DATABASE_URL=postgresql+asyncpg://updater:secure-password@db:5432/insight_updater
DB_NAME=insight_updater
DB_USER=updater
DB_PASSWORD=change-me-db-password
# ============================================================================= # =============================================================================
# REDIS (for Socket.io pub/sub, caching, rate limiting) # REDIS (for Socket.io pub/sub, caching, rate limiting)
+10 -3
View File
@@ -1,4 +1,4 @@
FROM python:3.11-slim FROM python:3.11-slim AS base
WORKDIR /app WORKDIR /app
@@ -25,8 +25,15 @@ COPY . .
# Create non-root user # Create non-root user
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
USER appuser
EXPOSE 8000 EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"] # Development stage: hot reload
FROM base AS development
USER appuser
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
# Production stage: no reload
FROM base AS production
USER appuser
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
+1
View File
@@ -8,6 +8,7 @@ services:
build: build:
context: ./backend context: ./backend
dockerfile: Dockerfile dockerfile: Dockerfile
target: development
container_name: insight-updater-backend container_name: insight-updater-backend
environment: environment:
- APP_ENV=development - APP_ENV=development