FROM ubuntu:24.04
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
    curl \
    nginx \
    python3 \
    python3-pip \
    python3-dev \
    build-essential \
    libpq-dev \
    libjpeg-dev \
    zlib1g-dev \
    libopenjp2-7-dev \
    vim \
    wget \
    zip \
    && rm -rf /var/lib/apt/lists/*
ADD requirements.txt requirements.txt
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
    rm -f /usr/lib/python*/EXTERNALLY-MANAGED && \
    /root/.local/bin/uv pip install --system --no-cache -r requirements.txt
ADD scripts/download_models.py /tmp/download_models.py
RUN python3 /tmp/download_models.py && rm /tmp/download_models.py
ADD api /emblem/api
ADD web /emblem/web
RUN cd /emblem/api && ./manage.py collectstatic --noinput
RUN mkdir -p /emblem/log
ADD scripts /emblem/scripts
ADD nginx.conf /emblem/nginx.conf
WORKDIR /emblem
CMD /emblem/scripts/entrypoint
