-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathDockerfile
164 lines (143 loc) · 4.48 KB
/
Dockerfile
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
###########################
# Builder image
###########################
FROM debian:bookworm-20250113 AS builder
ENV V_RStudio=R-4.4.2
ENV V_ShinyServer=v1.5.23.1030
RUN apt-get update && apt-get install -y \
gfortran \
libreadline6-dev \
libx11-dev \
libxt-dev \
libpng-dev \
libjpeg-dev \
libcairo2-dev \
xvfb \
libbz2-dev \
libzstd-dev \
liblzma-dev \
libcurl4-openssl-dev \
texinfo \
texlive \
texlive-fonts-extra \
screen \
wget \
tar \
xz-utils \
coreutils \
libpcre2-dev \
git \
apt-utils \
sed \
make \
cmake \
g++ \
default-jdk && \
rm -rf /var/lib/apt/lists/*
#Install R with blas and lapack support. Remove '--with-blas --with-lapack' to disable
WORKDIR /usr/local/src
RUN wget https://cran.rstudio.com/src/base/R-4/${V_RStudio}.tar.gz && \
tar zxvf ${V_RStudio}.tar.gz && \
cd /usr/local/src/${V_RStudio} && \
./configure --enable-R-shlib --with-blas --with-lapack && \
make -j4 && \
make -j4 install && \
cd /usr/local/src/ && \
rm -rf ${V_RStudio}*
#Install shiny-server with fix for arm architectures
WORKDIR /
RUN git clone --depth 1 --branch ${V_ShinyServer} https://github.com/rstudio/shiny-server.git && \
mkdir shiny-server/tmp
COPY binding.gyp /shiny-server/tmp/binding.gyp
ARG PYTHON=`which python3`
WORKDIR /shiny-server/tmp/
RUN mkdir ../build
RUN cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DPYTHON="$PYTHON" ../
RUN make -j4
RUN ../external/node/install-node.sh
# add node and npm paths respectively
ENV PATH=$PATH:/shiny-server/ext/node/bin/:/shiny-server/bin/
RUN node ../ext/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure
RUN node ../ext/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js --python="$PYTHON" rebuild
WORKDIR /shiny-server/
RUN npm --python="${PYTHON}" install --no-optional
RUN npm --python="${PYTHON}" install --no-optional --unsafe-perm
RUN npm --python="${PYTHON}" rebuild
WORKDIR /shiny-server/tmp/
RUN make -j4 install
###########################
# Production image
###########################
FROM debian:bookworm-20250113 AS shiny
COPY --from=builder /usr/local/bin/R /usr/local/bin/R
COPY --from=builder /usr/local/lib/R /usr/local/lib/R
COPY --from=builder /usr/local/bin/Rscript /usr/local/bin/Rscript
COPY --from=builder /usr/local/shiny-server /usr/local/shiny-server
WORKDIR /
RUN useradd -r -m shiny
RUN ln -s /usr/local/shiny-server/bin/shiny-server /usr/bin/shiny-server
#Create folder structure and set permissions
RUN mkdir -p /var/log/shiny-server && \
chown shiny /var/log/shiny-server && \
chmod -R 777 /var/log/shiny-server && \
mkdir -p /srv/shiny-server && \
chmod -R 777 /srv/shiny-server && \
mkdir -p /var/lib/shiny-server && \
chmod -R 777 /var/lib/shiny-server && \
mkdir -p /etc/shiny-server && \
chmod -R 777 /srv/shiny-server
#Shiny server configuration
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf
#Init file for installing R-packages from host
COPY init.sh /etc/shiny-server/init.sh
RUN chmod 777 /etc/shiny-server/init.sh
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gfortran \
libreadline6-dev \
libcurl4-openssl-dev \
ca-certificates \
libcairo2-dev \
xvfb \
libx11-dev \
libxt-dev \
libpng-dev \
libjpeg-dev \
libbz2-dev \
libzstd-dev \
liblzma-dev \
libatomic1 \
libgomp1 \
libpcre2-8-0 \
libssl-dev \
libxml2-dev \
g++ \
make && \
rm -rf /var/lib/apt/lists/*
#Preload hello world project
COPY hello/* /srv/shiny-server/hello/
#Prevent installation from hanging for multi-arch builds due to insufficient ram
RUN R -e "install.packages(c('shiny', 'Cairo'), repos='http://cran.rstudio.com/', clean = TRUE, Ncpus = 2)"
ENTRYPOINT ["/etc/shiny-server/init.sh"]
###########################
# Devtools Production image
###########################
FROM shiny AS shiny-with-devtools
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libzmq3-dev \
libharfbuzz-dev \
libfribidi-dev \
libfreetype6-dev \
libpng-dev \
libtiff5-dev \
libjpeg-dev \
build-essential \
libcurl4-openssl-dev \
libxml2-dev \
libssl-dev \
libfontconfig1-dev \
libgit2-dev && \
rm -rf /var/lib/apt/lists/*
# installing devtools
RUN R -e "install.packages('devtools', repos='http://cran.rstudio.com/', type='source', clean = TRUE, Ncpus = 2)"