-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (54 loc) · 2.03 KB
/
Dockerfile
File metadata and controls
66 lines (54 loc) · 2.03 KB
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
# ===========================================================================
# Stage 1: Dependencies (cached layer -- only rebuilds when DESCRIPTION changes)
# ===========================================================================
FROM rocker/r-ver:4.4.2 AS deps
# Headless rgl (no X11 display in Docker)
ENV RGL_USE_NULL=TRUE
# System libraries needed by R packages
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
libgl1-mesa-dev \
libglu1-mesa-dev \
libpng-dev \
libfreetype6-dev \
libharfbuzz-dev \
libfribidi-dev \
libfontconfig1-dev \
zlib1g-dev \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy only dependency-defining file for cache optimization
COPY DESCRIPTION /tmp/pkg/DESCRIPTION
# Install all R packages (PPM binaries where available)
RUN Rscript -e " \
install.packages('remotes', repos='https://cloud.r-project.org'); \
# Core dependencies \
install.packages(c('Rcpp', 'shiny', 'bslib', 'colourpicker', \
'viridisLite', 'memoise', 'cachem', 'config', 'here', 'grDevices'), \
repos='https://cloud.r-project.org'); \
# GitHub-only packages (archived from CRAN) \
remotes::install_github('stla/cxhull'); \
remotes::install_github('stla/tessellation'); \
"
# ===========================================================================
# Stage 2: Application (fast rebuild on code changes)
# ===========================================================================
FROM deps AS app
# Create app user (HF Spaces runs as uid 1000)
RUN useradd -m -u 1000 appuser
# Copy package source and install (compiles Rcpp C++)
COPY . /tmp/spiralizer-src
RUN cd /tmp/spiralizer-src && \
R CMD INSTALL --no-test-load . && \
rm -rf /tmp/spiralizer-src
# Set up the Shiny app directory
RUN mkdir -p /app
COPY inst/app/ /app/
RUN chown -R appuser:appuser /app
USER appuser
WORKDIR /app
EXPOSE 7860
CMD ["Rscript", "-e", "shiny::runApp('/app', host='0.0.0.0', port=7860, launch.browser=FALSE)"]