-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
31 lines (20 loc) · 975 Bytes
/
Copy pathDockerfile
File metadata and controls
31 lines (20 loc) · 975 Bytes
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
FROM alpine:latest AS builder
RUN apk update && apk add build-base git
WORKDIR /
RUN git clone --depth 1 https://github.com/richfelker/musl-cross-make.git /musl-cross-make
WORKDIR /musl-cross-make
ARG TARGET
RUN echo '#!/bin/sh' > /usr/local/bin/static-gcc && \
echo 'exec gcc -static --static "$@"' >> /usr/local/bin/static-gcc && \
echo '#!/bin/sh' > /usr/local/bin/static-g++ && \
echo 'exec g++ -static --static "$@"' >> /usr/local/bin/static-g++ && \
chmod +x /usr/local/bin/static-gcc /usr/local/bin/static-g++
RUN echo 'COMMON_CONFIG += CC="static-gcc"' > config.mak && \
echo 'COMMON_CONFIG += CXX="static-g++"' >> config.mak && \
echo 'COMMON_CONFIG += --disable-shared' >> config.mak && \
echo "TARGET = ${TARGET}" >> config.mak && \
echo 'OUTPUT = /musl' >> config.mak
RUN LDFLAGS="-static --static -s -Wl,--strip-all" make && \
LDFLAGS="-static --static -s -Wl,--strip-all" make install
FROM scratch
COPY --from=builder /musl /musl