File size: 2,688 Bytes
b385912
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5375c2e
 
 
 
b385912
 
 
 
 
0f680ac
b385912
5375c2e
 
 
 
 
 
 
 
 
 
 
b385912
5375c2e
b385912
 
 
5375c2e
 
b385912
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# syntax=docker/dockerfile:1.6

# ---- Stage 1: build the Vue SPA ----
FROM node:20-alpine AS frontend
WORKDIR /app
COPY src/frontend/package*.json ./
RUN npm ci
COPY src/frontend ./
RUN npm run build

# ---- Stage 2: backend runtime, mirrors the local website_c mamba env ----
FROM mambaorg/micromamba:1.5.10

USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
      build-essential libgl1 libglib2.0-0 git curl ca-certificates \
    && rm -rf /var/lib/apt/lists/*
USER $MAMBA_USER

# Conda half: Python 3.9, rdkit, boost, cairo, …
COPY --chown=$MAMBA_USER:$MAMBA_USER environment.yml /tmp/environment.yml
RUN micromamba install -y -n base -f /tmp/environment.yml \
    && micromamba clean --all --yes
ARG MAMBA_DOCKERFILE_ACTIVATE=1

# Pip half: GPU torch (cu118), torch-geometric, Django, DRF, …
COPY --chown=$MAMBA_USER:$MAMBA_USER src/backend/requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir \
      --extra-index-url https://download.pytorch.org/whl/cu118 \
      -r /tmp/requirements.txt

# karateclub 1.3.3 falsely caps numpy<1.23; install without its setup.py
# resolving that, real runtime deps are already covered by requirements.txt.
RUN pip install --no-cache-dir --no-deps karateclub==1.3.3

# Application code + research repo + built SPA
WORKDIR /app
COPY --chown=$MAMBA_USER:$MAMBA_USER src/backend /app/backend
COPY --chown=$MAMBA_USER:$MAMBA_USER src/research /app/research
COPY --chown=$MAMBA_USER:$MAMBA_USER --from=frontend /app/dist /app/backend/dist
COPY --chown=$MAMBA_USER:$MAMBA_USER --chmod=0755 entrypoint.sh /entrypoint.sh

# /app/research is the unified root for code, configs, Loader caches and
# downloaded weights.  Already owned by mambauser via the COPY --chown above
# — snapshot_download writes new files into it at runtime.

# Settings.py derives every research path (configs, code, results, weights)
# from these two roots.  We unify them — snapshot_download writes new
# checkpoint files into the research tree alongside the bundled code,
# configs and Loader caches.  Any mambauser-owned file under /app/research
# is writable at runtime; the read-only image layer holds the originals.
# Override CHECKPOINTS_ROOT (e.g. to /data/checkpoints on a paid HF Space
# with persistent storage) to point downloads elsewhere.
ENV RESEARCH_ROOT=/app/research \
    CHECKPOINTS_ROOT=/app/research \
    SPA_DIST_DIR=/app/backend/dist \
    DJANGO_SETTINGS_MODULE=research_api.settings \
    PYTHONUNBUFFERED=1 \
    PORT=7860 \
    HF_HUB_ENABLE_HF_TRANSFER=1

WORKDIR /app/backend
RUN python manage.py collectstatic --noinput

EXPOSE 7860
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh", "/entrypoint.sh"]