Files
mockupAWS/Dockerfile.backend
Luca Sacchi Ricciardi e88050c2e4
Some checks failed
CI/CD - Build & Test / Backend Tests (push) Has been cancelled
CI/CD - Build & Test / Frontend Tests (push) Has been cancelled
CI/CD - Build & Test / Security Scans (push) Has been cancelled
CI/CD - Build & Test / Docker Build Test (push) Has been cancelled
CI/CD - Build & Test / Terraform Validate (push) Has been cancelled
Deploy to Production / Build & Test (push) Has been cancelled
Deploy to Production / Security Scan (push) Has been cancelled
Deploy to Production / Build Docker Images (push) Has been cancelled
Deploy to Production / Deploy to Staging (push) Has been cancelled
Deploy to Production / E2E Tests (push) Has been cancelled
Deploy to Production / Deploy to Production (push) Has been cancelled
E2E Tests / Run E2E Tests (push) Has been cancelled
E2E Tests / Visual Regression Tests (push) Has been cancelled
E2E Tests / Smoke Tests (push) Has been cancelled
fix: resolve Docker database connection issues - COMPLETE
Major fixes to database connectivity in Docker:

1. Fix alembic.ini - Changed localhost to postgres (line 90)
   - This was the root cause of localhost connection errors

2. Fix database.py default - Changed localhost to postgres
   - Ensures correct default when env var not set

3. Fix config.py default - Changed localhost to postgres
   - Consistent configuration across all files

4. Fix .env file - Changed DATABASE_URL from localhost to postgres
   - Prevents local dev config from overriding Docker config

5. Update Dockerfile.backend - Add debug logging to verify env vars

6. Fix docker-compose.yml frontend port - Changed 3000 to 8888

7. Fix Celery commands - Use 'uv run celery' instead of just 'celery'

8. Remove obsolete 'version' attribute from docker-compose.yml

Verification:
- DATABASE_URL env var: postgresql+asyncpg://postgres:postgres@postgres:5432/mockupaws 
- Backend now connects to postgres:5432 instead of localhost 
- Frontend accessible at http://localhost:8888 

Note: There's a separate migration error with index creation
(idx_logs_recent using NOW() - requires IMMUTABLE function).
This is a database migration issue, not a connection issue.
2026-04-07 22:48:41 +02:00

30 lines
651 B
Docker

# Dockerfile.backend
# Backend FastAPI production image
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Install uv
RUN pip install uv
# Copy dependency files
COPY pyproject.toml uv.lock ./
# Install dependencies
RUN uv sync --frozen --no-dev
# Copy application code
COPY src/ ./src/
COPY alembic/ ./alembic/
COPY alembic.ini ./
# Run migrations and start application
CMD ["sh", "-c", "echo 'DATABASE_URL from env: '$DATABASE_URL && uv run alembic upgrade head && uv run uvicorn src.main:app --host 0.0.0.0 --port 8000"]