FROM python:3.10-slim # Set working directory WORKDIR /app # Install dependencies (including PostgreSQL client for pg_isready) RUN apt-get update && apt-get install -y \ gcc \ libpq-dev \ postgresql-client \ --no-install-recommends && \ rm -rf /var/lib/apt/lists/* # Copy requirements first to leverage Docker caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the full application code COPY . . # Default command (or override via docker-compose) CMD ["sh", "-c", "until pg_isready -h db -p 5432; do echo '[web] waiting for db…'; sleep 1; done && python app.py"]