|
| 1 | +FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 |
| 2 | + |
| 3 | +ENV PYTHONDONTWRITEBYTECODE 1 |
| 4 | +ENV PYTHONUNBUFFERED 1 |
| 5 | +ENV NVIDIA_VISIBLE_DEVICES all |
| 6 | +ENV NVIDIA_DRIVER_CAPABILITIES compute,utility |
| 7 | + |
| 8 | +WORKDIR /app |
| 9 | + |
| 10 | +ARG NODE_MAJOR=22 |
| 11 | + |
| 12 | +RUN apt-get update \ |
| 13 | + && apt-get install -y --no-install-recommends \ |
| 14 | + ca-certificates \ |
| 15 | + curl \ |
| 16 | + gnupg \ |
| 17 | + build-essential \ |
| 18 | + libglib2.0-0 \ |
| 19 | + libsm6 \ |
| 20 | + libxext6 \ |
| 21 | + libxrender1 \ |
| 22 | + libgomp1 \ |
| 23 | + libfontconfig1 \ |
| 24 | + ffmpeg \ |
| 25 | + libgl1-mesa-glx \ |
| 26 | + libgl1-mesa-dri \ |
| 27 | + libglu1-mesa \ |
| 28 | + python3 \ |
| 29 | + python3-pip \ |
| 30 | + python3-dev \ |
| 31 | + && mkdir -p /etc/apt/keyrings \ |
| 32 | + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ |
| 33 | + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ |
| 34 | + && apt-get update \ |
| 35 | + && apt-get install -y --no-install-recommends nodejs \ |
| 36 | + && rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \ |
| 37 | + && apt-get clean \ |
| 38 | + && useradd --create-home python \ |
| 39 | + && chown python:python -R /app |
| 40 | + |
| 41 | +USER python |
| 42 | + |
| 43 | +COPY --chown=python:python requirements*.txt ./ |
| 44 | + |
| 45 | +RUN pip3 install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 |
| 46 | + |
| 47 | +RUN pip3 install --no-cache-dir -r requirements.txt |
| 48 | + |
| 49 | +ENV DEBUG="false" \ |
| 50 | + PYTHONUNBUFFERED="true" \ |
| 51 | + PYTHONDONTWRITEBYTECODE="1" \ |
| 52 | + PATH="${PATH}:/home/python/.local/bin" \ |
| 53 | + USER="python" \ |
| 54 | + QT_QPA_PLATFORM="offscreen" \ |
| 55 | + CUDA_VISIBLE_DEVICES="0" \ |
| 56 | + HF_HOME="/app/.cache/huggingface" \ |
| 57 | + WEB_CONCURRENCY="2" |
| 58 | + |
| 59 | +COPY --chown=python:python package.json tailwind.config.js ./ |
| 60 | + |
| 61 | +RUN npm install |
| 62 | + |
| 63 | +COPY --chown=python:python . . |
| 64 | + |
| 65 | +RUN mkdir -p static/css staticfiles media tmp |
| 66 | + |
| 67 | +RUN chmod +x ./startup.sh |
| 68 | + |
| 69 | +RUN chmod +x ./download-models.sh |
| 70 | +RUN ./download-models.sh |
| 71 | + |
| 72 | +ARG HF_TOKEN |
| 73 | +ENV HF_TOKEN=${HF_TOKEN} |
| 74 | +RUN if [ -n "$HF_TOKEN" ]; then \ |
| 75 | + echo "Downloading HuggingFace models..."; \ |
| 76 | + python3 download-hf-models.py; \ |
| 77 | + else \ |
| 78 | + echo "HF_TOKEN not provided - models will be downloaded at runtime"; \ |
| 79 | + fi |
| 80 | + |
| 81 | +RUN npm run build |
| 82 | + |
| 83 | +RUN python3 manage.py collectstatic --no-input --verbosity 2 |
| 84 | + |
| 85 | +RUN python3 manage.py migrate |
| 86 | + |
| 87 | +HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ |
| 88 | + CMD curl -f http://localhost:8000/admin/login/ || exit 1 |
| 89 | + |
| 90 | +EXPOSE 8000 |
| 91 | + |
| 92 | +CMD ["./startup.sh"] |
0 commit comments