FROM python:3.10-slim

WORKDIR /app

# Install postgresql-client for pg_isready
RUN apt-get update && apt-get install -y \
    postgresql-client \
    && rm -rf /var/lib/apt/lists/*

# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the startup script and your application code
COPY . .

# Make the script executable
RUN chmod +x wait-for-postgres.sh
RUN chmod +x start.sh

# Use the full path for the entrypoint
ENTRYPOINT ["/app/start.sh"]