forked from bitwalker/alpine-erlang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.arm
151 lines (134 loc) · 4.79 KB
/
Dockerfile.arm
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
FROM arm64v8/alpine:3.12.0 AS build
# Important! Update this no-op ENV variable when this Dockerfile
# is updated with the current date. It will force refresh of all
# of the base images and things like `apt-get update` won't be using
# old cached versions when the Dockerfile is built.
ENV REFRESHED_AT=2020-07-20 \
LANG=en_US.UTF-8 \
HOME=/opt/app/ \
TERM=xterm \
ERLANG_VERSION=23.0.3
# Add tagged repos as well as the edge repo so that we can selectively install edge packages
RUN \
echo "@main http://dl-cdn.alpinelinux.org/alpine/v3.12/main" >> /etc/apk/repositories && \
echo "@community http://dl-cdn.alpinelinux.org/alpine/v3.12/community" >> /etc/apk/repositories && \
echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories
# Upgrade Alpine and base packages
RUN apk --no-cache --update --available upgrade
# Install bash and Erlang/OTP deps
RUN \
apk add --no-cache --update pcre@edge && \
apk add --no-cache --update \
bash \
ca-certificates \
openssl-dev \
ncurses-dev \
unixodbc-dev \
zlib-dev
# Install Erlang/OTP build deps
RUN \
apk add --no-cache --virtual .erlang-build \
dpkg-dev \
dpkg \
binutils \
git \
autoconf \
build-base \
perl-dev
WORKDIR /tmp/erlang-build
COPY patches /tmp/patches
# Clone, Configure, Build
RUN \
# Shallow clone Erlang/OTP
git clone -b OTP-$ERLANG_VERSION --single-branch --depth 1 https://github.com/erlang/otp.git . && \
# Erlang/OTP build env
export ERL_TOP=/tmp/erlang-build && \
export PATH=$ERL_TOP/bin:$PATH && \
export CPPFlAGS="-D_BSD_SOURCE $CPPFLAGS" && \
# Configure
./otp_build autoconf && \
./configure \
--prefix=/usr/local \
--build="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
--sysconfdir=/etc \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--without-javac \
--without-wx \
--without-debugger \
--without-observer \
--without-jinterface \
--without-cosEvent\
--without-cosEventDomain \
--without-cosFileTransfer \
--without-cosNotification \
--without-cosProperty \
--without-cosTime \
--without-cosTransactions \
--without-et \
--without-gs \
--without-ic \
--without-megaco \
--without-orber \
--without-percept \
--without-typer \
--enable-threads \
--enable-shared-zlib \
--enable-ssl=dynamic-ssl-lib \
--enable-hipe && \
make -j4
# Install to temporary location
RUN \
make DESTDIR=/tmp install && \
# Strip install to reduce size
ln -s /tmp/usr/local/lib/erlang /usr/local/lib/erlang && \
/tmp/usr/local/bin/erl -eval "beam_lib:strip_release('/tmp/usr/local/lib/erlang/lib')" -s init stop > /dev/null && \
(/usr/bin/strip /tmp/usr/local/lib/erlang/erts-*/bin/* || true) && \
rm -rf /tmp/usr/local/lib/erlang/usr/ && \
rm -rf /tmp/usr/local/lib/erlang/misc/ && \
for DIR in /tmp/usr/local/lib/erlang/erts* /tmp/usr/local/lib/erlang/lib/*; do \
rm -rf ${DIR}/src/*.erl; \
rm -rf ${DIR}/doc; \
rm -rf ${DIR}/man; \
rm -rf ${DIR}/examples; \
rm -rf ${DIR}/emacs; \
rm -rf ${DIR}/c_src; \
done && \
rm -rf /tmp/usr/local/lib/erlang/erts-*/lib/ && \
rm /tmp/usr/local/lib/erlang/erts-*/bin/dialyzer && \
rm /tmp/usr/local/lib/erlang/erts-*/bin/erlc && \
rm /tmp/usr/local/lib/erlang/erts-*/bin/typer && \
rm /tmp/usr/local/lib/erlang/erts-*/bin/ct_run
### Final Image
FROM arm64v8/alpine:3.12.0
MAINTAINER Paul Schoenfelder <[email protected]>
ENV LANG=en_US.UTF-8 \
HOME=/opt/app/ \
# Set this so that CTRL+G works properly
TERM=xterm \
PATH=/usr/local/bin:${PATH}
# Copy Erlang/OTP installation
COPY --from=build /tmp/usr/local /usr/local
WORKDIR ${HOME}
RUN \
# Create default user and home directory, set owner to default
adduser -s /bin/sh -u 1001 -G root -h "${HOME}" -S -D default && \
chown -R 1001:0 "${HOME}" && \
# Add tagged repos as well as the edge repo so that we can selectively install edge packages
echo "@main http://dl-cdn.alpinelinux.org/alpine/v3.12/main" >> /etc/apk/repositories && \
echo "@community http://dl-cdn.alpinelinux.org/alpine/v3.12/community" >> /etc/apk/repositories && \
echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
# Upgrade Alpine and base packages
apk --no-cache --update --available upgrade && \
# Install bash and Erlang/OTP deps
apk add --no-cache --update pcre@edge && \
apk add --no-cache --update \
bash \
ca-certificates \
openssl \
ncurses \
unixodbc \
zlib && \
# Update ca certificates
update-ca-certificates --fresh
CMD ["/usr/bin/bash"]