|
|
|
|
|
FROM python:3.14-slim |
|
|
|
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
|
|
|
RUN apt-get update && apt-get install -y \ |
|
|
build-essential \ |
|
|
git \ |
|
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
|
|
|
COPY requirements.txt . |
|
|
|
|
|
|
|
|
RUN pip install --upgrade pip |
|
|
|
|
|
|
|
|
RUN pip install --no-cache-dir -r requirements.txt |
|
|
|
|
|
|
|
|
RUN pip install git+https://github.com/huggingface/transformers@8fb854cac869b42c87a7bd15d9298985c5aea96e |
|
|
|
|
|
RUN --mount=type=secret,id=SECRET_KEY,mode=0444,required=true \ |
|
|
sh -c 'printf "SECRET_KEY=%s\n" "$(cat /run/secrets/SECRET_KEY)" >> .env' |
|
|
|
|
|
RUN --mount=type=secret,id=HUGGINGFACEHUB_API_TOKEN,mode=0444,required=true \ |
|
|
sh -c 'printf "HUGGINGFACEHUB_API_TOKEN=%s\n" "$(cat /run/secrets/HUGGINGFACEHUB_API_TOKEN)" >> .env' |
|
|
|
|
|
ARG ALLOWED_HOSTS |
|
|
ARG CSRF_TRUSTED_ORIGINS |
|
|
|
|
|
RUN printf "ALLOWED_HOSTS=%s\n" "${ALLOWED_HOSTS}" >> .env |
|
|
RUN printf "CSRF_TRUSTED_ORIGINS=%s\n" "${CSRF_TRUSTED_ORIGINS}" >> .env |
|
|
|
|
|
|
|
|
COPY . . |
|
|
|
|
|
|
|
|
RUN python manage.py migrate --noinput || true |
|
|
|
|
|
|
|
|
EXPOSE 7860 |
|
|
|
|
|
|
|
|
ENV DJANGO_SETTINGS_MODULE=backend.settings |
|
|
ENV PYTHONUNBUFFERED=1 |
|
|
ENV DEBUG=False |
|
|
ENV BUILD_MODE='production' |
|
|
|
|
|
|
|
|
|
|
|
CMD uvicorn backend.asgi:application --host 0.0.0.0 --port ${PORT:-7860} --workers 1 |
|
|
|
|
|
|