-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile.distroless
78 lines (63 loc) · 1.83 KB
/
Dockerfile.distroless
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
# Backup libs so we know what to copy later to runtime image
# Note: Only debug flavor has `find`
FROM gcr.io/distroless/cc:debug as runtime
# distroless debug uses busybox
SHELL ["/busybox/sh", "-c"]
RUN find /lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ -name '*.so*' > /shared-libs.list
FROM gcc:latest as build
# Reset to default
SHELL ["/bin/sh", "-c"]
COPY --from=runtime /shared-libs.list /shared-libs.list
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libboost-dev \
libboost-system-dev \
libboost-thread-dev \
libgmp-dev \
libcurl4-openssl-dev \
&& rm -rf /var/lib/apt/lists/*
# debian:stretch only has cmake-3.7...
RUN wget -qO- "https://cmake.org/files/v3.12/cmake-3.12.1-Linux-x86_64.tar.gz" | \
tar --strip-components=1 -xz -C /usr/local
WORKDIR /app
COPY extern extern
COPY cmake cmake
COPY include include
COPY test test
COPY scripts scripts
COPY CMakeLists.txt sepilinker.cpp ./
# build!
WORKDIR /app/build
RUN cmake \
-DCMAKE_FLAGS_EXTRA=-w \
-DCMAKE_EXE_LINKER_FLAGS_EXTRA=-static-libstdc++ \
.. \
&& make sel -j $(nproc)
RUN mkdir /deps; \
echo sel | while read bin; do \
ldd $bin | cut -d' ' -f 3 | grep -F .so | while read lib; do \
if ! grep -Fq $lib /shared-libs.list; then \
echo copy dependency $lib; \
cp -L $lib /deps; \
fi; \
done; \
done
# generating keys
WORKDIR /app/data
RUN ../scripts/genkeys.sh .
#FROM runtime
FROM gcr.io/distroless/cc:debug
WORKDIR /log
WORKDIR /app
COPY --from=build /app/build/sel /app/sel
COPY --from=build /deps /deps
# openssl keys
COPY --from=build /app/data /data
# json schemes, default config and circuit files
COPY data/*.json /data/
COPY data/circ /data/circ
# find libraries in the correct order
ENV LD_LIBRARY_PATH=/lib/x86_64-linux-gnu/:/deps/
EXPOSE 8161
EXPOSE 1337-1344
ENTRYPOINT ["/app/sel"]