Geoeasy commited on
Commit
80c1e4a
·
verified ·
1 Parent(s): 364ce28

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +47 -7
Dockerfile CHANGED
@@ -1,21 +1,61 @@
1
  # --- Dockerfile ---
2
  FROM rocker/shiny:latest
3
 
 
4
  # utilitário para normalizar EOL e pacotes R
5
  RUN apt-get update && apt-get install -y --no-install-recommends dos2unix && \
6
- R -e "install.packages(c('httr2'))" && \
7
- rm -rf /var/lib/apt/lists/*
8
 
9
- # app Shiny
10
- COPY app.R /srv/shiny-server/
11
 
12
- # script de inicialização
 
13
  COPY init.sh /init.sh
14
 
 
15
  # normaliza CRLF -> LF, ajusta perms e ownership
16
  RUN dos2unix /srv/shiny-server/app.R /init.sh && \
17
- chmod +x /init.sh && \
18
- chown -R shiny:shiny /srv/shiny-server
 
19
 
20
  EXPOSE 7860
21
  CMD ["/init.sh"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # --- Dockerfile ---
2
  FROM rocker/shiny:latest
3
 
4
+
5
  # utilitário para normalizar EOL e pacotes R
6
  RUN apt-get update && apt-get install -y --no-install-recommends dos2unix && \
7
+ R -e "install.packages(c('httr2'))" && \
8
+ rm -rf /var/lib/apt/lists/*
9
 
 
 
10
 
11
+ # app Shiny e script de inicialização
12
+ COPY app.R /srv/shiny-server/
13
  COPY init.sh /init.sh
14
 
15
+
16
  # normaliza CRLF -> LF, ajusta perms e ownership
17
  RUN dos2unix /srv/shiny-server/app.R /init.sh && \
18
+ chmod +x /init.sh && \
19
+ chown -R shiny:shiny /srv/shiny-server
20
+
21
 
22
  EXPOSE 7860
23
  CMD ["/init.sh"]
24
+
25
+
26
+ # --- init.sh ---
27
+ #!/bin/bash
28
+ set -Eeuo pipefail
29
+
30
+
31
+ # Executa a app sem shiny-server, usando a porta do Space
32
+ exec R -e "shiny::runApp('/srv/shiny-server', host='0.0.0.0', port=as.integer(Sys.getenv('PORT','7860')))"
33
+ # --- init.sh ---
34
+ #!/bin/bash
35
+ set -Eeuo pipefail
36
+ PORT_TO_USE="${PORT:-7860}"
37
+
38
+
39
+ # Gera config do shiny-server usando a porta do Spaces
40
+ cat > /etc/shiny-server/shiny-server.conf <<EOF
41
+ run_as shiny;
42
+ server {
43
+ listen ${PORT_TO_USE};
44
+ location / {
45
+ site_dir /srv/shiny-server;
46
+ log_dir /var/log/shiny-server;
47
+ directory_index on;
48
+ }
49
+ }
50
+ EOF
51
+
52
+
53
+ exec /usr/bin/shiny-server
54
+
55
+
56
+ # --- .gitattributes ---
57
+ # Força LF em ambientes Windows
58
+ * text=auto eol=lf
59
+ *.sh text eol=lf
60
+ *.R text eol=lf
61
+