-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDockerfile
197 lines (177 loc) · 13.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
#Start from ubuntu 20.04 as a base
FROM ubuntu:22.04 AS builder
#Install needed packages
RUN apt update && \
apt install -y software-properties-common && \
add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
apt update && \
apt install -y \
g++-11 \
gcc-11 \
cmake \
autoconf \
libtool \
vim \
curl \
git \
perl \
zlib1g-dev \
zlib1g \
yasm \
texinfo \
subversion \
apt-utils \
wget \
lzip
#Set GCC-11 and G++-11 as the default compilers
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11 && \
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 11 && \
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 11 && \
update-alternatives --set c++ /usr/bin/g++ && \
update-alternatives --set cc /usr/bin/gcc
#Set working directory
WORKDIR /tmp
#Build variable
ARG BUILDTHREADS=8
#Copy all dependencies of YAFU
#Note: the repository for this code can be found here: https://sourceforge.net/p/msieve/code/HEAD/tree/trunk/
COPY ./docker/msieve-code-r1044-trunk /tmp/msieve
#Install it all in the right order
RUN wget https://github.com/FACT0RN/GMP/releases/download/release_6.2.1/gmp-6.2.1.tar.lz && \
tar --lzip -xf gmp-6.2.1.tar.lz && \
cd /tmp/gmp-6.2.1 && \
autoreconf -i && \
find . -type f -exec touch {} + && \
chmod +x ./mpn/m4-ccas && \
./configure --enable-cxx && \
make -j $BUILDTHREADS && \
make install && \
mkdir -p /users/buhrow/src/c/gmp_install/gmp-6.2.0/lib && \
cp /tmp/gmp-6.2.1/.libs/libgmp.a /users/buhrow/src/c/gmp_install/gmp-6.2.0/lib/libgmp.a && \
#Install GMP-ECM
cd /tmp && \
git clone https://gitlab.inria.fr/zimmerma/ecm.git && \
cd ecm && \
git checkout master && \
autoreconf -i && \
ls /usr/local/lib && \
ls /usr/local/include && \
touch configure && \
./configure --with-gmp=/usr/local/ && \
make -j $BUILDTHREADS && \
make ecm-params && \
make -j $BUILDTHREADS && \
make install && \
cd /tmp && \
mv ecm gmp-ecm && \
#Build ggnfs sievers
cd /tmp && \
git clone https://github.com/FACT0RN/ggnfs.git && \
cd ggnfs/src/experimental/lasieve4_64 && \
./build.sh && \
mkdir /tmp/ggnfs_bin && \
mv gnfs-lasieve4I11e /tmp/ggnfs/ && \
mv gnfs-lasieve4I12e /tmp/ggnfs/ && \
mv gnfs-lasieve4I13e /tmp/ggnfs/ && \
mv gnfs-lasieve4I14e /tmp/ggnfs/ && \
mv gnfs-lasieve4I15e /tmp/ggnfs/ && \
mv gnfs-lasieve4I16e /tmp/ggnfs/ && \
#Build msieve
cd /tmp/msieve && \
make all NO_ZLIB=1 ECM=1 && \
#Build ytools
cd /tmp && \
git clone https://github.com/bbuhrow/ytools.git && \
cd /tmp/ytools && \
make -j $BUILDTHREADS CC=gcc-11 CPP=g++-11 CXX=g++-11 LD=g++-11 && \
#Build ysieve
cd /tmp && \
git clone https://github.com/bbuhrow/ysieve.git && \
cd /tmp/ysieve && \
make -j $BUILDTHREADS && \
#Install mpir
cd /tmp && \
git clone https://github.com/wbhart/mpir.git && \
cd mpir && \
./autogen.sh && \
touch configure && \
./configure && \
make && \
make install && \
#Build YAFU
cd /tmp && \
git clone https://github.com/bbuhrow/yafu.git && \
cd /tmp/yafu && \
git checkout ecfeb34c87222e7becf4829e22f4899f7dd5bfc7 && \
make yafu NFS=1
#Copy yafu ini file
COPY docker/yafu.ini /tmp/yafu
#Give permissions to use sievers
RUN chmod +x /tmp/ggnfs/gnfs-lasieve4*
#Create lighter container
FROM ubuntu:22.04
WORKDIR /tmp
RUN apt update && apt install -y \
libgmp-dev \
libcrypto++8 \
libcrypto++-dev \
python3-minimal \
python3-pip && \
pip3 install --upgrade pip && \
pip3 install sympy \
gmpy2 \
numpy \
base58 \
factordb-python
WORKDIR /tmp/factoring
#Copy the entire repo into the image
COPY . .
RUN ./script/build.sh
##GMP library
COPY --from=builder /usr/lib/x86_64-linux-gnu/libgmp.so.10 /usr/lib/x86_64-linux-gnu/libgmp.so.10
COPY --from=builder /usr/lib/x86_64-linux-gnu/libgmp.so.10.4.1 /usr/lib/x86_64-linux-gnu/libgmp.so.10.4.1
COPY --from=builder /usr/local/lib/libgmpxx.so.4.6.1 /usr/local/lib/libgmpxx.so.4.6.1
COPY --from=builder /usr/local/lib/libgmp.so.10 /usr/local/lib/libgmp.so.10
COPY --from=builder /usr/local/lib/libgmpxx.so.4 /usr/local/lib/libgmpxx.so.4
COPY --from=builder /usr/local/lib/libgmpxx.a /usr/local/lib/libgmpxx.a
COPY --from=builder /usr/local/lib/libgmp.so /usr/local/lib/libgmp.so
COPY --from=builder /usr/local/lib/libgmp.a /usr/local/lib/libgmp.a
COPY --from=builder /usr/local/lib/libgmpxx.so /usr/local/lib/libgmpxx.so
COPY --from=builder /usr/local/lib/libgmp.so.10.4.1 /usr/local/lib/libgmp.so.10.4.1
COPY --from=builder /usr/local/lib/libgmpxx.la /usr/local/lib/libgmpxx.la
COPY --from=builder /usr/local/lib/libgmp.la /usr/local/lib/libgmp.la
#COPY Executables
COPY --from=builder /tmp/ggnfs/gnfs-lasieve4I11e /tmp/ggnfs-bin/gnfs-lasieve4I11e
COPY --from=builder /tmp/ggnfs/gnfs-lasieve4I12e /tmp/ggnfs-bin/gnfs-lasieve4I12e
COPY --from=builder /tmp/ggnfs/gnfs-lasieve4I13e /tmp/ggnfs-bin/gnfs-lasieve4I13e
COPY --from=builder /tmp/ggnfs/gnfs-lasieve4I14e /tmp/ggnfs-bin/gnfs-lasieve4I14e
COPY --from=builder /tmp/ggnfs/gnfs-lasieve4I15e /tmp/ggnfs-bin/gnfs-lasieve4I15e
COPY --from=builder /tmp/ggnfs/gnfs-lasieve4I16e /tmp/ggnfs-bin/gnfs-lasieve4I16e
COPY --from=builder /tmp/gmp-ecm/ecm /tmp/gmp-ecm/ecm
COPY --from=builder /tmp/mpir/printf/.libs/libprintf.a /tmp/mpir/printf/.libs/libprintf.a
COPY --from=builder /tmp/mpir/mpf/.libs/libmpf.a /tmp/mpir/mpf/.libs/libmpf.a
COPY --from=builder /tmp/mpir/.libs/libmpir.a /tmp/mpir/.libs/libmpir.a
COPY --from=builder /tmp/mpir/mpq/.libs/libmpq.a /tmp/mpir/mpq/.libs/libmpq.a
COPY --from=builder /tmp/mpir/mpn/.libs/libmpn.a /tmp/mpir/mpn/.libs/libmpn.a
COPY --from=builder /tmp/mpir/scanf/.libs/libscanf.a /tmp/mpir/scanf/.libs/libscanf.a
COPY --from=builder /tmp/mpir/mpz/.libs/libmpz.a /tmp/mpir/mpz/.libs/libmpz.a
COPY --from=builder /tmp/mpir/fft/.libs/libfft.a /tmp/mpir/fft/.libs/libfft.a
COPY --from=builder /tmp/mpir/.libs/libmpir.so.23 /tmp/mpir/.libs/libmpir.so.23
COPY --from=builder /tmp/mpir/.libs/libmpir.so.23.0.3 /tmp/mpir/.libs/libmpir.so.23.0.3
COPY --from=builder /tmp/mpir/.libs/libmpir.so /tmp/mpir/.libs/libmpir.so
COPY --from=builder /tmp/msieve/libmsieve.a /tmp/msieve/libmsieve.a
COPY --from=builder /tmp/ysieve/libysieve.a /tmp/ysieve/libysieve.a
COPY --from=builder /tmp/ytools/libytools.a /tmp/ytools/libytools.a
COPY --from=builder /tmp/yafu/libyecm.a /tmp/yafu/libyecm.a
COPY --from=builder /tmp/yafu/libynfs.a /tmp/yafu/libynfs.a
COPY --from=builder /tmp/yafu/libysiqs.a /tmp/yafu/libysiqs.a
COPY --from=builder /tmp/yafu/yafu /tmp/yafu/yafu
#Copy yafu ini file
COPY docker/yafu.ini /tmp/yafu
COPY docker/yafu.ini /tmp/factoring/python
ENV OMP_PROC_BIND="TRUE"
ENV MSIEVE_BIN="/tmp/ggnfs-bin"
ENV YAFU_BIN="/tmp/yafu/yafu"
WORKDIR /tmp/factoring/python
CMD bash