FROM registry.gitlab.com/euphon/themblem:ubuntu-24.04
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
    curl \
    nginx \
    python3 \
    python3-pip \
    python3-dev \
    python3-venv \
    build-essential \
    libpq-dev \
    libjpeg-dev \
    zlib1g-dev \
    libopenjp2-7-dev \
    vim \
    wget \
    zip \
    unzip \
    && rm -rf /var/lib/apt/lists/*
ADD requirements.txt requirements.txt
RUN rm -f /usr/lib/python*/EXTERNALLY-MANAGED && \
    pip3 install uv --index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
    uv pip install --system --no-cache -r requirements.txt --default-index https://pypi.tuna.tsinghua.edu.cn/simple
ADD scripts/download_models.py /tmp/download_models.py
RUN HF_ENDPOINT=https://hf-mirror.com 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
