-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
188 lines (169 loc) · 6.15 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
FROM debian:stretch
ENV USER=rstudio
ARG PANDOC_TEMPLATES_VERSION
ARG BUILD_DATE
ENV PANDOC_TEMPLATES_VERSION ${PANDOC_TEMPLATES_VERSION:-1.18}
ENV TERM=xterm \
DEBIAN_FRONTEND=noninteractive \
PATH=/usr/lib/rstudio-server/bin:$PATH
# Select Debian mirror
RUN sed -i 's%deb.debian.org%mirror.bytemark.co.uk%' /etc/apt/sources.list
# Set locale
RUN apt-get update \
&& apt-get install -y --no-install-recommends locales \
&& echo "en_GB.UTF-8 UTF-8" >> /etc/locale.gen \
&& locale-gen en_GB.utf8 \
&& /usr/sbin/update-locale LANG=en_GB.UTF-8 \
&& rm -rf /var/lib/apt/lists/*
ENV LC_ALL=en_GB.UTF-8 \
LANG=en_GB.UTF-8
# Install R Dependencies
RUN apt-get update \
&& apt-get install -y software-properties-common apt-transport-https gnupg \
&& add-apt-repository 'deb https://cran.ma.imperial.ac.uk/bin/linux/debian stretch-cran34/' \
&& apt-key adv --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF' \
&& apt-get update \
&& apt-get install -y \
r-base \
r-base-dev \
r-recommended \
libopenblas-base \
curl \
wget
## Add a default CRAN mirror
RUN echo "options(repos = c(CRAN = 'https://cran.rstudio.com/'), download.file.method = 'libcurl')" >> /etc/R/Rprofile.site \
## Add a library directory (for user-installed packages)
&& mkdir -p /usr/local/lib/R/site-library \
&& chown root:staff /usr/local/lib/R/site-library \
&& chmod g+wx /usr/local/lib/R/site-library \
## Fix library path
&& echo "R_LIBS_USER='/usr/local/lib/R/site-library'" >> /etc/R/Renviron \
&& echo "R_LIBS=\${R_LIBS-'/usr/local/lib/R/site-library:/usr/local/lib/R/library:/usr/lib/R/library'}" >> /etc/R/Renviron \
## install packages from date-locked MRAN snapshot of CRAN
&& [ -z "$BUILD_DATE" ] && BUILD_DATE=$(TZ="America/Los_Angeles" date -I) || true \
&& MRAN=https://mran.microsoft.com/snapshot/${BUILD_DATE} \
&& echo MRAN=$MRAN >> /etc/environment \
&& export MRAN=$MRAN \
## MRAN becomes default only in versioned images
## Use littler installation scripts
&& Rscript -e "install.packages(c('littler', 'docopt'), repo = '$MRAN')" \
&& ln -s /usr/local/lib/R/site-library/littler/examples/install2.r /usr/local/bin/install2.r \
&& ln -s /usr/local/lib/R/site-library/littler/examples/installGithub.r /usr/local/bin/installGithub.r \
&& ln -s /usr/local/lib/R/site-library/littler/bin/r /usr/local/bin/r \
## TEMPORARY WORKAROUND to get more robust error handling for install2.r prior to littler update
&& curl -O /usr/local/bin/install2.r https://github.com/eddelbuettel/littler/raw/master/inst/examples/install2.r \
&& chmod +x /usr/local/bin/install2.r \
&& rm -rf /var/lib/apt/lists/*
## Download and install RStudio server & dependencies
## Attempts to get detect latest version, otherwise falls back to version given in $VER
## Symlink pandoc, pandoc-citeproc so they are available system-wide
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git \
libapparmor1 \
libcurl4-openssl-dev \
libedit2 \
libssl-dev \
lsb-release \
psmisc \
python-setuptools \
sudo \
rrdtool \
openssh-client \
libxml2-dev \
texinfo \
texlive \
texlive-latex-extra \
default-jre \
default-jdk \
bzip2 \
libbz2-dev \
libpcre3-dev \
liblzma-dev \
libicu-dev \
libpng-dev \
libjpeg-dev \
libpoppler-cpp-dev \
libgeos-dev \
libgdal-dev \
libproj-dev \
&& rm -rf /var/lib/apt/lists/* \
&& wget -O libssl1.0.0.deb http://ftp.debian.org/debian/pool/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u6_amd64.deb \
&& dpkg -i libssl1.0.0.deb \
&& rm libssl1.0.0.deb
# Install RStudio
RUN wget -q https://download2.rstudio.org/rstudio-server-1.0.143-amd64.deb \
&& dpkg -i rstudio-server-1.0.143-amd64.deb \
&& rm rstudio-server-*-amd64.deb \
# Install pandoc
&& ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc /usr/local/bin \
&& ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc-citeproc /usr/local/bin \
&& wget https://github.com/jgm/pandoc-templates/archive/${PANDOC_TEMPLATES_VERSION}.tar.gz \
&& mkdir -p /opt/pandoc/templates && tar zxf ${PANDOC_TEMPLATES_VERSION}.tar.gz \
&& cp -r pandoc-templates*/* /opt/pandoc/templates && rm -rf pandoc-templates* \
&& mkdir /root/.pandoc && ln -s /opt/pandoc/templates /root/.pandoc/templates \
## Configure R
&& mkdir -p /etc/R \
&& echo '\n\
\n .libPaths("~/R/library") \
\n# Configure httr to perform out-of-band authentication if HTTR_LOCALHOST \
\n# is not set since a redirect to localhost may not work depending upon \
\n# where this Docker container is running. \
\nif(is.na(Sys.getenv("HTTR_LOCALHOST", unset=NA))) { \
\n options(httr_oob_default = TRUE) \
\n}' >> /etc/R/Rprofile.site \
&& echo "PATH=\"${PATH}\"" >> /etc/R/Renviron \
&& echo "r-libs-user=~/R/library" >> /etc/rstudio/rsession.conf \
## Configure RStudio profile
&& echo '\n\
\n[*] \
\nmax-memory-mb = 12288 \
\n' >> /etc/rstudio/profiles
# Install R Packages
RUN R -e "install.packages(c(\
'Rcpp', \
'aws.s3', \
'aws.signature', \
'base64enc', \
'base64enc', \
'bitops', \
'caTools', \
'codetools', \
'curl', \
'devtools', \
'digest', \
'digest', \
'evaluate', \
'formatR', \
'highr', \
'htmltools', \
'httr', \
'jsonlite', \
'knitr', \
'markdown', \
'readr', \
'rmarkdown', \
'rprojroot', \
'shiny', \
'stringr', \
'tidyverse', \
'xml2', \
'yaml' \
))" \
# Install R S3 package
&& R -e "install.packages(c('aws.signature', 'aws.s3'), \
repos = c('cloudyr' = 'http://cloudyr.github.io/drat'))" \
# Install MOJ S3tools package
&& R -e "devtools::install_github('moj-analytical-services/s3tools')" \
# Install webshot/phantomjs for Doc/PDF with JS graphs in it
&& R -e "install.packages('webshot')" \
&& R -e "webshot::install_phantomjs()" \
&& mv /root/bin/phantomjs /usr/bin/phantomjs \
&& chmod a+rx /usr/bin/phantomjs
# Configure git
RUN git config --system credential.helper 'cache --timeout=3600' \
&& git config --system push.default simple
COPY start.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/start.sh
EXPOSE 8787
CMD ["/usr/local/bin/start.sh"]