forked from fholzhauser/docker-erlang-otp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContainerfile
82 lines (76 loc) · 2.97 KB
/
Containerfile
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
ARG ALPINE_VERSION=alpine:3.16
FROM $ALPINE_VERSION
ARG OTP_VERSION
ARG OTP_DOWNLOAD_SHA256
ARG REBAR3_VERSION
ARG REBAR3_DOWNLOAD_SHA256
ENV OTP_VERSION=$OTP_VERSION \
REBAR3_VERSION=$REBAR3_VERSION
LABEL org.opencontainers.image.version=$OTP_VERSION
ADD ./patches /patches
RUN set -xe \
&& OTP_DOWNLOAD_URL="https://github.com/erlang/otp/releases/download/OTP-$OTP_VERSION/otp_src_$OTP_VERSION.tar.gz" \
&& apk upgrade --no-cache \
&& apk add --no-cache --virtual .fetch-deps \
curl \
ca-certificates \
&& curl -fSL -o otp-src.tar.gz "$OTP_DOWNLOAD_URL" \
&& echo "$OTP_DOWNLOAD_SHA256 otp-src.tar.gz" | sha256sum -c - \
&& apk add --no-cache --virtual .build-deps \
--repository=http://dl-cdn.alpinelinux.org/alpine/v3.12/main \
bash \
dpkg-dev dpkg \
gcc \
g++ \
libc-dev \
linux-headers=5.4.5-r1 \
make \
autoconf \
ncurses-dev \
openssl-dev \
unixodbc-dev \
lksctp-tools-dev \
tar \
&& apk add --no-cache --virtual .quilt-deps \
--repository=https://dl-cdn.alpinelinux.org/alpine/v3.19/community \
quilt \
&& export ERL_TOP="/usr/src/otp_src_${OTP_VERSION%%@*}" \
&& mkdir -vp $ERL_TOP \
&& tar -xzf otp-src.tar.gz -C $ERL_TOP --strip-components=1 --no-same-owner --no-same-permissions \
&& rm otp-src.tar.gz \
&& ( cd $ERL_TOP \
&& if [ -f /patches/$OTP_VERSION/series ]; then QUILT_PATCHES=/patches/$OTP_VERSION quilt push -a ; fi \
&& ./otp_build autoconf \
&& gnuArch="$(dpkg-architecture --query DEB_HOST_GNU_TYPE)" \
&& ./configure --build="$gnuArch" \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install ) \
&& rm -rf $ERL_TOP \
&& rm -rf /patches \
&& find /usr/local -regex '/usr/local/lib/erlang/\(lib/\|erts-\).*/\(man\|doc\|obj\|c_src\|emacs\|info\|examples\)' | xargs rm -rf \
&& find /usr/local -name src | xargs -r find | grep -v '\.hrl$' | xargs rm -v || true \
&& find /usr/local -name src | xargs -r find | xargs rmdir -p || true \
&& scanelf --nobanner -E ET_EXEC -BF '%F' --recursive /usr/local | xargs -r strip --strip-all \
&& scanelf --nobanner -E ET_DYN -BF '%F' --recursive /usr/local | xargs -r strip --strip-unneeded \
&& runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)" \
&& REBAR3_DOWNLOAD_URL="https://github.com/erlang/rebar3/archive/${REBAR3_VERSION}.tar.gz" \
&& curl -fSL -o rebar3-src.tar.gz "$REBAR3_DOWNLOAD_URL" \
&& echo "${REBAR3_DOWNLOAD_SHA256} rebar3-src.tar.gz" | sha256sum -c - \
&& mkdir -p /usr/src/rebar3-src \
&& tar -xzf rebar3-src.tar.gz -C /usr/src/rebar3-src --strip-components=1 --no-same-owner --no-same-permissions \
&& rm rebar3-src.tar.gz \
&& cd /usr/src/rebar3-src \
&& HOME=$PWD ./bootstrap \
&& install -v ./rebar3 /usr/local/bin/ \
&& rm -rf /usr/src/rebar3-src \
&& apk add --virtual .erlang-rundeps \
$runDeps \
lksctp-tools \
ca-certificates \
&& apk del .fetch-deps .build-deps .quilt-deps
CMD ["erl"]