FROM python:3.13-alpine

# install nginx and runtime deps, plus a build-deps group for uv sync
RUN apk add --no-cache  nginx  libffi  openssl
RUN apk add --no-cache --virtual .build-deps  build-base  libffi-dev  openssl-dev  python3-dev py3-pip

    # grab uv CLI
RUN pip install uv

WORKDIR /app

# install your Python deps
COPY uv.lock pyproject.toml ./
RUN uv sync --frozen --no-cache \
    # drop build tools once deps are in place
    && apk del .build-deps

# copy in the rest of your Django project
COPY . .

# collectstatic
RUN uv run python manage.py collectstatic --noinput

# copy nginx config
COPY nginx.conf /etc/nginx/nginx.conf

EXPOSE 8088

# start.sh should launch both nginx and uvicorn
COPY start.sh /start.sh
RUN chmod +x /start.sh

CMD ["/start.sh"]
