-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
108 lines (81 loc) · 4.61 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
ARG EMSCRIPTEN_VERSION=3.1.64
ARG EMSDK_IMAGE=docker.io/emscripten/emsdk
# Build libsodium
FROM ${EMSDK_IMAGE}:${EMSCRIPTEN_VERSION} AS SODIUM
ARG LIBSODIUM_VERSION=1.0.20-stable
ADD https://download.libsodium.org/libsodium/releases/libsodium-${LIBSODIUM_VERSION}.tar.gz .
RUN tar xvf libsodium-${LIBSODIUM_VERSION}.tar.gz \
&& cd libsodium-stable \
&& sed -i -e 's/WASM_INITIAL_MEMORY=4MB/WASM_INITIAL_MEMORY=8MB/g' dist-build/emscripten.sh \
&& dist-build/emscripten.sh --sumo
# Build openssl
FROM ${EMSDK_IMAGE}:${EMSCRIPTEN_VERSION} AS OPENSSL
ARG OPENSSL_VERSION=3.1.6
ADD https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz .
ADD https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz.sha256 .
RUN bash -c 'echo "$(cat openssl-${OPENSSL_VERSION}.tar.gz.sha256) openssl-${OPENSSL_VERSION}.tar.gz" | sha256sum --check || exit 1' \
&& tar xvf openssl-${OPENSSL_VERSION}.tar.gz \
&& cd openssl-${OPENSSL_VERSION} \
&& emconfigure ./Configure linux-generic64 no-asm no-threads no-engine no-hw no-weak-ssl-ciphers no-dtls no-shared no-dso --prefix=/emsdk/upstream \
&& sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile \
&& sed -i '/^CFLAGS/ s/$/ -D__STDC_NO_ATOMICS__=1/' Makefile \
&& sed -i '/^CXXFLAGS/ s/$/ -D__STDC_NO_ATOMICS__=1/' Makefile \
&& emmake make -j$(nproc) all \
&& emmake make install
# Build libcrypt4gh
FROM ${EMSDK_IMAGE}:${EMSCRIPTEN_VERSION} AS LIBCRYPT4GH
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt-get update -q \
&& apt-get upgrade -yq -o Dpkg::Options::="--force-confold" \
&& apt-get install -yq autoconf
COPY --from=SODIUM /src/libsodium-stable/libsodium-js-sumo/include/ /emsdk/upstream/include/
COPY --from=SODIUM /src/libsodium-stable/libsodium-js-sumo/lib/ /emsdk/upstream/lib/
ADD https://api.github.com/repos/CSCfi/libcrypt4gh/compare/main...HEAD /dev/null
RUN git clone https://github.com/CSCfi/libcrypt4gh
# We'll skip linking libraries since emcc only produces static libraries
# Linking sodium at this point causes a linker conflict – thus cutting out $(LIBS)
RUN export EMCC_CFLAGS="-I/emsdk/upstream/include -L/emsdk/upstream/lib" \
&& export LDFLAGS="-L/emsdk/upstream/lib" \
&& cd libcrypt4gh \
&& autoreconf --install \
&& sed -i 's/$(LIBS) //' Makefile.in \
&& emconfigure ./configure --prefix=/emsdk/upstream \
&& emmake make \
&& emmake make install
# Build libcrypt4gh-keys
FROM ${EMSDK_IMAGE}:${EMSCRIPTEN_VERSION} AS LIBCRYPT4GHKEYS
COPY --from=SODIUM /src/libsodium-stable/libsodium-js-sumo/include/ /emsdk/upstream/include/
COPY --from=SODIUM /src/libsodium-stable/libsodium-js-sumo/lib/ /emsdk/upstream/lib/
COPY --from=OPENSSL /emsdk/upstream/include/ /emsdk/upstream/include/
COPY --from=OPENSSL /emsdk/upstream/lib/ /emsdk/upstream/lib/
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt-get update -q \
&& apt-get upgrade -yq -o Dpkg::Options::="--force-confold" \
&& apt-get install -yq autoconf build-essential pkg-config
ADD https://api.github.com/repos/cscfi/libcrypt4gh-keys/compare/main...HEAD /dev/null
RUN git clone https://github.com/CSCfi/libcrypt4gh-keys.git
# We'll skip linking libraries since emcc only produces static libraries
# Linking sodium at this point causes a linker conflict – thus cutting out $(LIBS)
RUN export EMCC_CFLAGS="-I/emsdk/upstream/include -L/emsdk/upstream/lib" \
&& export LDFLAGS="-L/emsdk/upstream/lib" \
&& cd libcrypt4gh-keys \
&& autoreconf --install \
&& sed -i 's/$(LIBS) //' Makefile.in \
&& emconfigure ./configure --prefix=/emsdk/upstream --with-openssl=/emsdk/upstream \
&& emmake make \
&& emmake make install
# Build wasm application
FROM ${EMSDK_IMAGE}:${EMSCRIPTEN_VERSION} AS WASMCRYPT
LABEL maintainer="CSC Developers"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.vcs-url="https://github.com/CSCfi/docker-emscripten-crypt4gh"
COPY --from=SODIUM /src/libsodium-stable/libsodium-js-sumo/include/ /emsdk/upstream/include/
COPY --from=SODIUM /src/libsodium-stable/libsodium-js-sumo/lib/ /emsdk/upstream/lib/
COPY --from=LIBCRYPT4GH /emsdk/upstream/include/ /emsdk/upstream/include/
COPY --from=LIBCRYPT4GH /emsdk/upstream/lib/ /emsdk/upstream/lib/
COPY --from=LIBCRYPT4GHKEYS /emsdk/upstream/include/ /emsdk/upstream/include/
COPY --from=LIBCRYPT4GHKEYS /emsdk/upstream/lib/ /emsdk/upstream/lib/
COPY build_wasm.sh /bin/build_wasm.sh
ENTRYPOINT ["/bin/build_wasm.sh"]
CMD ["all"]