FROM python:3.11-slim

# Create a working directory
WORKDIR /app
ENV PIP_ROOT_USER_ACTION=ignore

# Copy project files
COPY . /app

RUN pip install --upgrade pip
RUN pip install poetry
RUN poetry install

# Set default port and allow override via environment variable
ENV PORT=8000
EXPOSE ${PORT}
ENV FORWARDED_ALLOW_IPS=*

# Use shell form so $PORT gets expanded at runtime
CMD poetry run gunicorn -k uvicorn.workers.UvicornWorker src.svindler_backend.main:app --bind 0.0.0.0:$PORT
