ARG UCC_PYTHON_BASE_IMAGE=python:3.11.9-slim-bookworm
FROM ${UCC_PYTHON_BASE_IMAGE}
ARG PIP_INDEX_URL=
ARG PIP_EXTRA_INDEX_URL=
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 PIP_NO_CACHE_DIR=1
WORKDIR /app
COPY app/requirements.txt /app/requirements.txt
RUN if [ -n "$PIP_INDEX_URL" ]; then python -m pip config set global.index-url "$PIP_INDEX_URL"; fi \
    && if [ -n "$PIP_EXTRA_INDEX_URL" ]; then python -m pip config set global.extra-index-url "$PIP_EXTRA_INDEX_URL"; fi \
    && python -m pip install --no-cache-dir -r /app/requirements.txt
COPY app/ /app/
RUN mkdir -p /data/static /data/media /data/imports
EXPOSE 8000
CMD ["gunicorn", "ucc_project.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "3", "--timeout", "120"]
