-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
266 lines (217 loc) · 10.2 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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
## <---- Create a clone of Ubuntu image
FROM ubuntu:focal
MAINTAINER Najla Ksouri <najlaksouri@gmail.com>
MAINTAINER Bruno Contreras Moreira <bcontreras@eead.csic.es>
## <---- Prevent to open interactive dialogs during the installation process
ENV DEBIAN_FRONTEND=noninteractive
## <---- Set the language environment in the docker container: should be included before installing any other package
RUN apt-get update \
&& apt-get install -y locales \
&& locale-gen en_US.UTF-8 \
&& update-locale LANG=en_US.UTF-8 \
&& apt-get autoremove
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
ENV LC_ALL en_US.UTF-8
## <---- Install required packages, including git
RUN apt-get install -y --no-install-recommends \
apt-transport-https \
git \
wget \
less \
vim-tiny \
vim \
time \
lsb-release \
# gnupg2 needed for gpg command and FOR R key installation
gnupg2 \
dirmngr \
ca-certificates\
software-properties-common \
&& rm -rf /var/lib/apt/lists/*
## <---- Add the CRAN repository to your system sources list
# commented out, use Ubuntu's instead, r-color-brewer complained
#RUN echo "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" > /etc/apt/sources.list.d/cran.list
#RUN gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \
# && gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9| apt-key add -
## <---- Now install R and littler, and create a link for littler in /usr/local/bin
## <---- Also set a default CRAN repo, and make sure littler knows about it too
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
littler \
r-cran-littler \
r-base \
r-base-dev \
r-recommended \
r-cran-rcolorbrewer \
&& echo 'options(repos = c(CRAN = "https://cloud.r-project.org/"), download.file.method = "libcurl")' >> /etc/R/Rprofile.site \
&& echo 'source("/etc/R/Rprofile.site")' >> /etc/littler.r \
&& ln -s /usr/share/doc/littler/examples/install.r /usr/local/bin/install.r \
&& ln -s /usr/share/doc/littler/examples/install2.r /usr/local/bin/install2.r \
&& ln -s /usr/share/doc/littler/examples/installGithub.r /usr/local/bin/installGithub.r \
&& ln -s /usr/share/doc/littler/examples/testInstalled.r /usr/local/bin/testInstalled.r \
&& install.r docopt \
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds \
&& rm -rf /var/lib/apt/lists/*
## <---- Create INSTALL_ROOT directory and set as working directory:
ENV INSTALL_ROOT=/packages
RUN echo $INSTALL_ROOT \
&& mkdir -p ${INSTALL_ROOT}/
WORKDIR /packages
## <---- Actually clone RSAT repository into your working dir and rename to rsat
RUN git clone https://github.com/rsa-tools/rsat-code.git --branch 20240828 --single-branch
RUN mv rsat-code rsat
# Repositories 'demo_files' and 'sample_ouput' are skipped to save space
# git clone https://github.com/rsa-tools/demo_files.git
# git clone https://github.com/rsa-tools/sample_outputs.git
## <---- Download licensed motif_databases, move to /packages/motif_databases and symb link
RUN wget --no-parent -r --reject "index.html*" https://rsat.eead.csic.es/plants/motif_databases/ \
&& mv /packages/rsat.eead.csic.es/plants/motif_databases/ /packages \
&& rm -rf /packages/rsat.eead.csic.es
RUN cd rsat/public_html/ \
&& ln -s ../../motif_databases/
## <---- Remove bulky motif_databases
RUN rm -rf /packages/motif_databases/cisBP2
RUN grep -v cisBP2 /packages/motif_databases/db_matrix_files.tab > /packages/motif_databases/db_matrix_files.filt.tab
RUN mv /packages/motif_databases/db_matrix_files.filt.tab /packages/motif_databases/db_matrix_files.tab
## <---- Declare the environment path and set the new working directory
ENV RSAT /packages/rsat
RUN echo $RSAT
WORKDIR $RSAT
## <---- define your IP, this step is needed to have access to web interface
ENV MY_IP "localhost"
RUN echo "MY_IP ${MY_IP}"
## <----Choose your RSAT site name
ENV RSAT_SITE=my_rsat
## <---- Configure RSAT to be used internally and in web server, this step is needed to generate the RSAT_config.bashrc
RUN perl perl-scripts/configure_rsat.pl -auto rsat=${RSAT} rsat_site=${RSAT_SITE} rsat_www=http://${MY_IP}/rsat/ \
rsat_ws=http://${MY_IP}/rsat/ package_manager="apt-get" ucsc_tools=1 ensembl_tools=1
## <---- Read config and run bash installation scripts: requires sudo and apt-utils
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
sudo \
apt-utils
######################################################## Notes ########################################################
# To run the bash installation scripts, we need sudo access
# To run source RSAT_config.bashrc we need a bash shell; however, the default shell for RUN instructions is ["/bin/sh", "-c"].
# Using SHELL instruction SHELL ["/bin/bash", "-c"], we can change default shell for subsequent RUN instructions in Dockerfile
# then RUN "source file" # now translates to: RUN /bin/bash -c "source file"
## <---- switch to bash
SHELL ["/bin/bash", "-c"]
## <---- make sure you are in your working dir
RUN cd ${RSAT}
WORKDIR ${RSAT}
## <---- Read config and run bash installation scripts
RUN source /packages/rsat/RSAT_config.bashrc \
&& bash installer/01_ubuntu_packages.bash \
&& bash installer/02_python_packages.bash
######################################################## Notes ########################################################
# When installinng python dependencies you might error with rpy2-3.5.12.tar.gz or PySimpleSOAP-1.16.2.tar.gz
# "note: This error originates from a subprocess, and is likely not a problem with pip"
# To fix this, we need to pgrade versions of pip, setuptools and wheel -> see installer/02_python_packages.bash
# end https://bobbyhadz.com/blog/python-note-this-error-originates-from-subprocess
RUN bash installer/03_install_rsat.bash \
&& bash installer/04_perl_packages.bash \
# && bash installer/06_install_organisms.bash \ skipped to save 243MB
&& bash installer/07_R-and-packages.bash \
&& bash installer/08_apache_config.bash \
&& bash installer/10_clean_unnecessary_files.bash
RUN echo "source ${RSAT}/RSAT_config.bashrc" >> /etc/bash.bashrc \
&& echo "service apache2 start" >> /etc/bash.bashrc
## <---- remove some uneeded folders to save space
RUN rm -rf ${RSAT}/ext_lib/ensemblgenomes*/ensembl-*/modules/t \
${RSAT}/ext_lib/ensemblgenomes*/ensembl-*/.git \
${RSAT}/ext_lib/bioperl*/bioperl-live/t \
${RSAT}/ext_lib/bioperl*/bioperl-live/.git \
${RSAT}/.git
## <---- add new user called rsat_user and give it permission to $RSAT
ENV RSATUSER="rsat_user"
ENV RSATPASS="rsat_2020"
ENV RSATUSERHOME="/home/${RSATUSER}"
ENV TESTPATH="${RSATUSERHOME}/test_data"
ENV EXTMOTIFPATH="${RSATUSERHOME}/ext_motifs"
RUN useradd ${RSATUSER} \
&& echo "${RSATUSER}:${RSATPASS}" | chpasswd \
&& adduser ${RSATUSER} sudo \
&& chown -R "${RSATUSER}:${RSATUSER}" ${RSAT} \
&& chmod 755 ${RSAT} \
&& mkdir -p ${TESTPATH} \
&& mkdir -p ${EXTMOTIFPATH} \
&& chmod -R a+w ${RSATUSERHOME}
## <---- Set env variables
ENV R_LIBS_SITE="${RSAT}/R-scripts/Rpackages/"
ENV PATH="${PATH}:${RSAT}/ext_lib/ensemblgenomes-44-97/ensembl-git-tools/bin:${RSAT}/python-scripts:${RSAT}/perl-scripts/parsers:${RSAT}/perl-scripts:${RSAT}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
## <---- Create new folder with test _data
ENV TESTMAKEURL="https://raw.githubusercontent.com/eead-csic-compbio/coexpression_motif_discovery/master/makefile/peak-motifs.mk"
ENV TESTRSATURL="https://raw.githubusercontent.com/eead-csic-compbio/coexpression_motif_discovery/master/peach/Modules/M11"
ENV TESTRSATFILEREMOTE="${TESTRSATURL}/genesM11.txt"
ENV TESTRSATFILELOCAL="${TESTPATH}/M11.txt"
ENV TESTMAKEFILELOCAL="${TESTPATH}/peak-motifs.mk"
RUN wget ${TESTRSATFILEREMOTE} -O ${TESTRSATFILELOCAL}
RUN wget ${TESTMAKEURL} -O ${TESTMAKEFILELOCAL}
# not needed unless installer/06_install_organisms.bash is run above
## <---- Rename the container's folder for installing genomes, local volume to be used instead,
# this also allows to use preinstalled genomes elsewhere in the file system.
#
# Note that ${RSAT}/public_html/data_container takes 243MB including
# Escherichia_coli_GCF_000005845.2_ASM584v2
# Escherichia_coli_K_12_substr__MG1655_uid57779
# Saccharomyces_cerevisiae
#
# This is a a result of installer/06_install_organisms.bash
#RUN mv ${RSAT}/public_html/data ${RSAT}/public_html/data_container
## <---- set default user and path
USER ${RSATUSER}
WORKDIR "/home/${RSATUSER}"
################################# Useful command lines #################################
#
#
## 1) Build RSAT Docker container
#
# export RSATDOCKERVERSION=`date '+%Y%m%d'`
# docker build --tag rsat:$RSATDOCKERVERSION --tag rsat:latest --force-rm --compress .
#
#
## 2) Create local folders for input data and results, outside the container, as these might be large
#
# mkdir -p ~/rsat_data/genomes ~/rsat_results
# chmod -R a+w ~/rsat_data/genomes ~/rsat_results
#
#
## 3) Launch Docker RSAT container:
#
# docker run --rm -v ~/rsat_data:/packages/rsat/public_html/data/ -v ~/rsat_results:/home/rsat_user/rsat_results -it rsat:latest
#
#
## 4) Download organism from public RSAT server, such as the Plants server.
## Other available servers: http://fungi.rsat.eu, http://metazoa.rsat.eu, http://protists.rsat.eu
#
# download-organism -v 2 -org Prunus_persica.Prunus_persica_NCBIv2.38 -server https://rsat.eead.csic.es/plants
#
#
## 5) Test container
#
# cd rsat_results
# make -f ../test_data/peak-motifs.mk RNDSAMPLES=2 all
#
#
## 6) Install any organism, please follow
## https://rsa-tools.github.io/managing-RSAT/genome_installation/install_organisms_FASTA_GTF.html
#
#
## 7) To connect to RSAT Web server running from Docker
#
# If you run Docker as a normal user Apache will not start properly and you will see these messages:
#
# * Starting Apache httpd web server apache2
# (13)Permission denied: AH00091: apache2: could not open error log file /var/log/apache2/error.log.
# AH00015: Unable to open logs
# Action 'start' failed.
# The Apache error log may have more information
#
# If you really want lo launch the Docker Web server launch tge container and do (see RSATPASS above):
#
# sudo service apache2 restart
# hostname -I
#
# open the following URL in your browser, using the obtained the IP address: http://172.17.0.2/rsat