File size: 2,711 Bytes
6493351
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ╔══════════════════════════════════════════════════════════════════╗
# β•‘  BubbleBusters β€” Hugging Face Space Dockerfile                   β•‘
# β•‘  Uses rocker/r-ver as base β€” R is pre-installed, no apt needed  β•‘
# β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

# rocker/r-ver:4.3 = Debian Bookworm + R 4.3 pre-installed
FROM rocker/r-ver:4.3

# ── 1. System libraries ──────────────────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
        python3 \
        python3-pip \
        python3-venv \
        libcurl4-openssl-dev \
        libssl-dev \
        libxml2-dev \
        libzmq3-dev \
        curl \
    && rm -rf /var/lib/apt/lists/*

# ── 2. Python packages FIRST β€” jupyter must exist before IRkernel ───
COPY requirements.txt /tmp/requirements.txt
RUN pip3 install --no-cache-dir --upgrade pip \
 && pip3 install --no-cache-dir -r /tmp/requirements.txt

# ── 3. R packages via Posit Package Manager (pre-built binaries) ────
RUN Rscript -e "\
    options(repos = c(CRAN = 'https://packagemanager.posit.co/cran/__linux__/bookworm/latest')); \
    install.packages(c( \
        'vctrs', 'rlang', 'pillar', \
        'readr', 'dplyr', 'tidyr', 'lubridate', \
        'ggplot2', 'MASS', 'zoo', 'jsonlite', 'scales' \
    ), Ncpus = 2)"

# ── 4. IRkernel β€” jupyter is now installed so installspec works ──────
RUN Rscript -e "\
    options(repos = c(CRAN = 'https://packagemanager.posit.co/cran/__linux__/bookworm/latest')); \
    install.packages('IRkernel')" \
 && Rscript -e "IRkernel::installspec(user = FALSE)"

# ── 5. Non-root user (Hugging Face Spaces requirement) ──────────────
RUN useradd -m -u 1000 user
USER user

ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

WORKDIR /home/user/app

# ── 6. App source ───────────────────────────────────────────────────
COPY --chown=user . .

# ── 7. Gradio networking ─────────────────────────────────────────────
ENV GRADIO_SERVER_NAME="0.0.0.0" \
    GRADIO_SERVER_PORT=7860

EXPOSE 7860

CMD ["python3", "app.py"]