-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
251 lines (229 loc) · 6.4 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
ARG CONDA_VERSION=py311_23.9.0-0
#########################################
# Base
#########################################
FROM docker.io/opensuse/leap:15.4 AS base
# Install general utilities:
# - R depends on which
# - R help needs less
# - r-devtools needs tar etc
RUN zypper refresh && \
zypper --non-interactive install \
which less \
tar gzip unzip \
&& \
zypper clean --all
#########################################
# Conda environment
#########################################
FROM base AS conda
# Install conda
ARG CONDA_VERSION
RUN curl https://repo.anaconda.com/miniconda/Miniconda3-$CONDA_VERSION-Linux-x86_64.sh -o conda.sh && \
bash conda.sh -b -p /conda && \
rm conda.sh && \
/conda/bin/conda clean -afy
# Create base R environment
ARG R_VERSION
RUN . /conda/etc/profile.d/conda.sh && \
conda create -p /conda/env -c conda-forge --override-channels --no-default-packages \
r-base=$R_VERSION \
&& \
/conda/bin/conda clean -afy
# Install common conda-available packages
RUN . /conda/etc/profile.d/conda.sh && \
conda activate /conda/env && \
conda install -c conda-forge --override-channels \
r-devtools \
r-remotes \
r-rcpp \
r-pbapply \
r-tidyverse \
r-sf \
r-terra \
&& \
/conda/bin/conda clean -afy
# Install other conda-available packages
RUN . /conda/etc/profile.d/conda.sh && \
conda activate /conda/env && \
conda install -c conda-forge --override-channels \
r-rcpparmadillo \
r-iterators \
r-sp \
r-raster \
r-rgbif \
r-rnaturalearth \
r-ncdf4 \
r-epi \
r-png \
r-keyring \
r-codetools \
r-geometries \
r-jsonify \
r-rapidjsonr \
r-sfheaders \
r-countrycode \
r-geojsonsf \
r-inlabru \
r-r.devices \
r-dbi \
r-rlang \
r-glue \
r-withr \
r-fmesher \
r-rgdal \
r-doParallel \
r-foreach \
r-doSNOW \
r-automap \
r-fasterize \
r-stars \
r-ggplot2 \
r-ggpubr \
r-tidyr \
r-viridis \
r-cowplot \
r-ggpmisc \
r-gridExtra \
# Packages for capfitogen
r-sp \
r-raster \
r-maptools \
r-dismo \
r-rgdal \
r-rgeos \
r-RJSONIO \
r-googleVis \
r-cluster \
r-ade4 \
r-labdsv \
r-mclust \
r-clustvarsel \
r-randomForest \
r-modeltools \
r-lattice \
r-flexmix \
r-fpc \
r-vegan \
r-adegenet \
# Packages for INLA
r-locfit \
r-ash \
r-multicool \
r-pracma \
r-hdrcde \
r-ks \
r-bitops \
r-rainbow \
r-RCurl \
r-fds \
r-deSolve \
r-fda \
r-jpeg \
r-TeachingDemos \
r-coda \
r-mcmc \
r-dotCall64 \
r-rbibutils \
r-MCMCpack \
r-gtools \
r-spam \
r-maps \
r-dfidx \
r-Formula \
r-lmtest \
r-Rdpack \
r-mnormt \
r-Deriv \
r-evd \
r-fields \
r-gsl \
r-markdown \
r-mlogit \
r-rgl \
r-sn \
r-splancs \
# Packages for sdm
r-dismo \
r-gbm \
r-rjava \
r-glmnet \
r-tree \
r-mda \
r-plotrix \
r-plotmo \
r-earth \
r-ranger \
r-shinybs \
r-crosstalk \
r-rsnns \
r-leaflet \
r-leaflet.providers \
&& \
/conda/bin/conda clean -afy
# Set default CRAN repository
RUN echo 'options(repos=c(CRAN="https://cloud.r-project.org"))' > /conda/env/lib/R/etc/Rprofile.site
# Install non-conda-available packages
RUN . /conda/etc/profile.d/conda.sh && \
conda activate /conda/env && \
Rscript -e 'install.packages(c( \
"blockCV", \
"ecmwfr", \
"giscoR", \
"tidyterra", \
"geodata", \
"mmap", \
"sdm", \
"usdm" \
))' && \
/conda/bin/conda clean -afy
# Install INLA
# See https://www.r-inla.org/download-install
RUN . /conda/etc/profile.d/conda.sh && \
conda activate /conda/env && \
Rscript -e 'install.packages("INLA",repos=c(getOption("repos"),INLA="https://inla.r-inla-download.org/R/stable"), dep=TRUE)' && \
# Bugfix: https://github.com/hrue/r-inla/issues/86#issuecomment-1837534618
Rscript -e 'install.packages("MatrixModels", type="source")' && \
# Fix permissions
find /conda/env/lib/R/library/INLA/ -type f -perm -u+x -exec chmod a+x {} \; && \
/conda/bin/conda clean -afy
# Install intSDM etc
RUN . /conda/etc/profile.d/conda.sh && \
conda activate /conda/env && \
Rscript -e 'devtools::install_github("PhilipMostert/PointedSDMs", dependencies=FALSE)' && \
# Bugfix: Installing intSDM directly from github doesn't work so we install it first from cran
Rscript -e 'install.packages("intSDM")' && \
Rscript -e 'devtools::install_github("PhilipMostert/intSDM", dependencies=FALSE)' && \
/conda/bin/conda clean -afy
# Install mraster
RUN . /conda/etc/profile.d/conda.sh && \
conda activate /conda/env && \
Rscript -e 'devtools::install_github("babaknaimi/mraster", dependencies=FALSE)' && \
/conda/bin/conda clean -afy
# Install KrigR
RUN . /conda/etc/profile.d/conda.sh && \
conda activate /conda/env && \
export R_REMOTES_NO_ERRORS_FROM_WARNINGS="true" && \
# dependencies=FALSE so that RcppArmadillo doesn't get reinstalled
Rscript -e 'devtools::install_github("ErikKusch/KrigR", dependencies=FALSE)' && \
/conda/bin/conda clean -afy
# Install remaining sdm dependencies (should be none)
RUN . /conda/etc/profile.d/conda.sh && \
conda activate /conda/env && \
Rscript -e 'sdm::installAll() ' && \
/conda/bin/conda clean -afy
# ENTRYPOINT ["bash"]
# Clean files not needed runtime
RUN find -L /conda/env/ -type f -name '*.a' -delete -print && \
find -L /conda/env/ -type f -name '*.js.map' -delete -print
#########################################
# Final container image
#########################################
FROM base
COPY --from=conda /conda/env/ /conda/env/
ENV PROJ_DATA=/conda/env/share/proj \
PATH=/conda/env/bin:$PATH \
R_KEYRING_BACKEND=env \
LC_ALL=C.UTF-8
ENTRYPOINT ["Rscript"]
CMD ["--help"]