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

# Use the full path for the entrypoint
ENTRYPOINT ["/app/wait-for-postgres.sh"]

# This is your application's original startup command
CMD ["/bin/bash", "-c", "python apply_test_schema.py && python insert_csv_embeddings.py && python main.py"]