-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_dockerfiles.py
238 lines (168 loc) · 6.03 KB
/
make_dockerfiles.py
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
import yaml
import os
import shutil
from pathlib import Path
# Here are reported the templated Dockerfiles, for each tool
# If you want to update them, please pay attention in escaping brackets {{}} and backslashes \\
DOCKERFILES = {
'graphaligner' : '''\
FROM continuumio/miniconda3:latest
RUN apt-get update && apt-get install -y git
RUN git clone https://github.com/maickrau/GraphAligner.git
WORKDIR /GraphAligner
RUN git checkout {}
RUN git submodule update --init --recursive
RUN conda env create -f CondaEnvironment.yml
RUN echo "source activate GraphAligner" >> ~/.bashrc
ENV PATH /opt/conda/envs/GraphAligner/bin:$PATH
RUN apt-get update && apt-get install -y g++ && apt-get install -y make
RUN make bin/GraphAligner
ENV PATH /GraphAligner/bin:$PATH
CMD ["/bin/bash"]
RUN mkdir results
RUN mkdir input_data
''',
'vg' : '''\
FROM mirror.gcr.io/library/ubuntu:20.04 AS base
RUN apt-get update && apt-get install -y git
RUN git clone --recursive https://github.com/vgteam/vg.git
WORKDIR /vg
RUN git checkout {}
RUN git submodule update --init --recursive
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
FROM base AS build
ARG THREADS=8
ARG TARGETARCH
RUN apt-get -qq -y update && \\
apt-get -qq -y upgrade && \\
apt-get -qq -y install sudo
RUN apt-get -qq -y update && apt-get -qq -y upgrade && apt-get -qq -y install \\
make git build-essential protobuf-compiler libprotoc-dev libjansson-dev libbz2-dev \\
libncurses5-dev automake gettext autopoint libtool jq bsdmainutils bc rs parallel npm \\
samtools curl unzip redland-utils librdf-dev cmake pkg-config wget gtk-doc-tools \\
raptor2-utils rasqal-utils bison flex gawk libgoogle-perftools-dev liblz4-dev liblzma-dev \\
libcairo2-dev libpixman-1-dev libffi-dev libcairo-dev libprotobuf-dev libboost-all-dev \\
tabix bcftools libzstd-dev pybind11-dev python3-pybind11
RUN if [ -z "${{TARGETARCH}}" ] || [ "${{TARGETARCH}}" = "amd64" ] ; then sed -i s/march=native/march=nehalem/ deps/sdsl-lite/CMakeLists.txt; fi
RUN . ./source_me.sh && CXXFLAGS="$(if [ -z "${{TARGETARCH}}" ] || [ "${{TARGETARCH}}" = "amd64" ] ; then echo " -march=nehalem "; fi)" CFLAGS="$(if [ -z "${{TARGETARCH}}" ] || [ "${{TARGETARCH}}" = "amd64" ] ; then echo " -march=nehalem "; fi)" make -j $((THREADS < $(nproc) ? THREADS : $(nproc))) deps
RUN . ./source_me.sh && CXXFLAGS="$(if [ -z "${{TARGETARCH}}" ] || [ "${{TARGETARCH}}" = "amd64" ] ; then echo " -march=nehalem "; fi)" make -j $((THREADS < $(nproc) ? THREADS : $(nproc))) objs
RUN . ./source_me.sh && CXXFLAGS="$(if [ -z "${{TARGETARCH}}" ] || [ "${{TARGETARCH}}" = "amd64" ] ; then echo " -march=nehalem "; fi)" make -j $((THREADS < $(nproc) ? THREADS : $(nproc))) static && strip -d bin/vg
ENV PATH /vg/bin:$PATH
RUN mkdir results
RUN mkdir input_data
''',
'astarix': '''\
FROM ubuntu:20.04
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \\
build-essential \\
libc-dev \\
python3 \\
python3-pip \\
git\\
cmake\\
&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/eth-sri/astarix
WORKDIR /astarix
RUN git checkout {}
RUN pip3 install pandas
# compile and test
RUN make && \\
make test
RUN mkdir results
RUN mkdir input_data
''',
'gwfa': '''\
FROM ubuntu:latest
RUN apt-get update && apt-get -y upgrade && apt-get -y install build-essential git zlib1g-dev
RUN git clone https://github.com/lh3/gwfa.git ./gwfa
WORKDIR ./gwfa
RUN git checkout {}
RUN make
RUN mkdir results
RUN mkdir input_data
''',
'sga': '''\
FROM gcc:latest
RUN apt-get update && \\
apt-get install -y cmake && \\
rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/Mirkocoggi/SGA
# RUN git clone https://github.com/haowenz/SGA
WORKDIR /SGA/extern
RUN git checkout {}
RUN rm -rf gfatools
RUN git clone https://github.com/lh3/gfatools.git
WORKDIR /SGA/extern/gfatools
RUN make
WORKDIR /SGA
RUN mkdir build
WORKDIR /SGA/build
RUN cmake -DSGAL_BUILD_TESTING=ON ..
RUN make
RUN ctest
RUN cp -r apps ..
WORKDIR /SGA
RUN mkdir results
RUN mkdir input_data
''',
'v-align': '''\
FROM gcc:latest
RUN git clone https://github.com/tcsatc/V-ALIGN
COPY utils/fasta_to_txt.py ./V-ALIGN
WORKDIR /V-ALIGN
RUN git checkout {}
WORKDIR /V-ALIGN/utils
RUN chmod u+x genfvs
WORKDIR /V-ALIGN
RUN make
RUN mkdir results
RUN mkdir input_data
''',
'gedmap': '''\
FROM ubuntu:22.04
RUN apt-get update && apt-get -y upgrade && apt-get -y install build-essential git cmake g++
WORKDIR /root
RUN git clone https://github.com/simongog/sdsl-lite.git
WORKDIR /root/sdsl-lite
RUN git checkout c32874c
RUN ./install.sh
WORKDIR /
RUN git clone https://github.com/thomas-buechler-ulm/gedmap.git
WORKDIR /gedmap
RUN git checkout {}
RUN make gedmap
RUN mkdir results
RUN mkdir input_data
'''
}
def main():
# Open the tools_config.yml file and read tools' configuration
with open('tools_config.yml', 'r') as file:
config = yaml.safe_load(file)
# Create the Dockerfiles folder, if it doesn't exist yet
if not os.path.exists('Dockerfiles'):
os.makedirs('Dockerfiles')
# Select Dockerfiles as working directory
DOCKERFILES_FOLDER = os.path.join(os.getcwd(), 'Dockerfiles')
os.chdir(DOCKERFILES_FOLDER)
# Eventually, remove previously existing folders
folder_list = [f for f in Path(DOCKERFILES_FOLDER).glob('**/*') if not f.is_file()]
for dir in folder_list:
shutil.rmtree(os.path.join(DOCKERFILES_FOLDER, dir))
# Create subfolders in Dockerfiles, one for each tested tool
for tool in config:
os.makedirs(tool)
# For each tool, create a Dockerfile in its subfolder
for tool in config:
os.chdir(os.path.join(DOCKERFILES_FOLDER, tool))
file_tmp = open('Dockerfile', 'w')
file_tmp.write(DOCKERFILES[tool.lower()].format(config[tool]['version']))
file_tmp.close()
# Print a success message
print('\nSuccessfully created dockerfiles for the following tools:')
for tool in config:
print(f'\t{tool}')
print()
if __name__ == '__main__':
main()