softwareDevelopment commited on
Commit
63d825a
·
verified ·
1 Parent(s): 29bc8d6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -18
Dockerfile CHANGED
@@ -1,39 +1,43 @@
1
  FROM rocker/shiny:4.3.2
2
 
3
- # Install system dependencies (with retry to handle transient mirror sync errors)
4
  RUN for i in 1 2 3; do \
5
  apt-get update -o Acquire::Retries=3 && break || sleep 10; \
6
  done \
7
- && apt-get install -y --fix-missing --no-install-recommends \
8
- libcurl4-openssl-dev \
9
- libssl-dev \
10
- libxml2-dev \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
  # Install required R packages
14
- RUN R -e "install.packages(c('shiny', 'htmltools'), repos='https://cran.rstudio.com/', dependencies=TRUE)"
15
 
16
- # HuggingFace Spaces runs on port 7860
17
  ENV PORT=7860
18
  EXPOSE 7860
19
 
20
- # Copy app files into the Shiny server directory
21
  COPY app.R /srv/shiny-server/app/app.R
22
 
23
- # Override Shiny Server config — logs redirected to /tmp (always writable by non-root)
24
- RUN printf 'run_as shiny;\n\nserver {\n listen 7860;\n\n location / {\n site_dir /srv/shiny-server/app;\n log_dir /tmp/shiny-logs;\n directory_index on;\n }\n}\n' \
25
- > /etc/shiny-server/shiny-server.conf
26
 
27
- # Create log dir and fix ALL permissions before switching to non-root user
28
  RUN mkdir -p /tmp/shiny-logs \
29
- && chown -R shiny:shiny /srv/shiny-server/app \
30
- && chmod -R 755 /srv/shiny-server/app \
31
  && chown -R shiny:shiny /tmp/shiny-logs \
32
- && chmod -R 777 /tmp/shiny-logs
 
 
 
33
 
34
- # HuggingFace requires the container to run as UID 1000
35
- RUN usermod -u 1000 shiny && groupmod -g 1000 shiny
 
36
 
 
37
  USER shiny
38
 
39
- CMD ["/usr/bin/shiny-server"]
 
1
  FROM rocker/shiny:4.3.2
2
 
3
+ # Install system dependencies (retry for robustness)
4
  RUN for i in 1 2 3; do \
5
  apt-get update -o Acquire::Retries=3 && break || sleep 10; \
6
  done \
7
+ && apt-get install -y --no-install-recommends \
8
+ libcurl4-openssl-dev \
9
+ libssl-dev \
10
+ libxml2-dev \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
  # Install required R packages
14
+ RUN R -e "install.packages(c('shiny','htmltools'), repos='https://cran.rstudio.com/', dependencies=TRUE)"
15
 
16
+ # Hugging Face uses port 7860
17
  ENV PORT=7860
18
  EXPOSE 7860
19
 
20
+ # Copy app
21
  COPY app.R /srv/shiny-server/app/app.R
22
 
23
+ # Fix UID/GID BEFORE permissions (important for HF Spaces)
24
+ RUN usermod -u 1000 shiny && groupmod -g 1000 shiny
 
25
 
26
+ # Create required writable directories
27
  RUN mkdir -p /tmp/shiny-logs \
28
+ && mkdir -p /tmp/shiny-bookmarks \
29
+ && chown -R shiny:shiny /srv/shiny-server \
30
  && chown -R shiny:shiny /tmp/shiny-logs \
31
+ && chown -R shiny:shiny /tmp/shiny-bookmarks \
32
+ && chmod -R 755 /srv/shiny-server \
33
+ && chmod -R 777 /tmp/shiny-logs \
34
+ && chmod -R 777 /tmp/shiny-bookmarks
35
 
36
+ # Override Shiny Server config
37
+ RUN printf "run_as shiny;\n\nserver {\n listen 7860;\n\n location / {\n site_dir /srv/shiny-server/app;\n log_dir /tmp/shiny-logs;\n bookmark_state_dir /tmp/shiny-bookmarks;\n directory_index on;\n }\n}\n" \
38
+ > /etc/shiny-server/shiny-server.conf
39
 
40
+ # Run as non-root (required by HF)
41
  USER shiny
42
 
43
+ CMD ["/usr/bin/shiny-server"]