2025-05-10 23:59:55 +00:00
|
|
|
FROM python:3.10-slim
|
|
|
|
|
2025-05-14 16:53:47 +00:00
|
|
|
# Set working directory
|
2025-05-10 23:59:55 +00:00
|
|
|
WORKDIR /app
|
|
|
|
|
2025-05-14 16:53:47 +00:00
|
|
|
# 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/*
|
2025-05-10 23:59:55 +00:00
|
|
|
|
2025-05-14 16:53:47 +00:00
|
|
|
# Copy requirements first to leverage Docker caching
|
2025-05-10 23:59:55 +00:00
|
|
|
COPY requirements.txt .
|
2025-05-14 16:53:47 +00:00
|
|
|
|
|
|
|
# Install Python dependencies
|
2025-05-10 23:59:55 +00:00
|
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
2025-05-14 16:53:47 +00:00
|
|
|
# Copy the full application code
|
2025-05-10 23:59:55 +00:00
|
|
|
COPY . .
|
|
|
|
|
2025-05-14 16:53:47 +00:00
|
|
|
# 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"]
|