-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile.toolchain
88 lines (76 loc) · 2.95 KB
/
Dockerfile.toolchain
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
# syntax=docker/dockerfile:1
ARG TARGET=x86_64-unknown-linux-musl
# https://hub.docker.com/_/ubuntu
FROM docker.io/library/ubuntu:22.04 AS build
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
WORKDIR /
ENV DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF-8 \
TZ=UTC \
TERM=xterm-256color
# Used for testing the GitHub workflow
# RUN echo "Building musl toolchain for target ${TARGET}"
# Make sure we have basic dev tools for building.
# We only build the gcc musl based toolchain here
# and use these compiled files later in other Docker builds.
# This saves time during the building of the actual libraries
# we want to build since the toolchain doesn't change that much anyway.
#
# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install -y \
build-essential \
gcc g++ cpp \
cmake \
libtool \
pkg-config \
curl \
file \
rsync \
texinfo \
ca-certificates \
--no-install-recommends \
&& \
# Cleanup apt
apt-get autoremove -y --purge && \
apt-get clean -y && \
rm -rf /var/cache/* /var/lib/apt/lists/* && \
# Default cleanups
find /var/log -type f -delete && \
# Pre-Create the /musl-cross-make directory
mkdir -pv /musl-cross-make
ARG TARGET
ARG MUSL_CROSS_MAKE_HASH=fd6be58297ee21fcba89216ccd0d4aca1e3f1c5c
ARG ARCH_COMMON_CONFIG=""
COPY config.mak /musl-cross-make/config.mak
# hadolint ignore=DL3003
RUN echo "Downloading musl-cross-make" && \
# Download musl-cross-make from https://github.com/richfelker/musl-cross-make based upon the provided $MUSL_CROSS_MAKE_HASH
curl -w"%{stderr}URL: %{url_effective}\nTime: %{time_total}\nSize: %{size_download}\n" --retry 3 \
-sSL "https://github.com/richfelker/musl-cross-make/archive/${MUSL_CROSS_MAKE_HASH}.tar.gz" | \
tar xzf - --strip-components=1 -C /musl-cross-make/ && \
mkdir -p /usr/local/musl && \
#
echo "Building musl toolchain for target ${TARGET}" && \
cd /musl-cross-make && \
# Build the actual toolchain here
# We store the toolchain in /usr/local/musl
make install "-j$(nproc)" > /dev/null && \
# Fix symlink to libc.so
ln -sfrn "/usr/local/musl/${TARGET}/lib/libc.so" "$(ls -1 /usr/local/musl/${TARGET}/lib/ld-*.so.1)" && \
# Cleanup
cd / && \
rm -rf /musl-cross-make && \
echo "Finished building target ${TARGET}"
# https://hub.docker.com/_/busybox
FROM docker.io/busybox:1.36.1-glibc
WORKDIR /
COPY --from=build /usr/local/musl /usr/local/musl
ENV PATH="${PATH}:/usr/local/musl/bin"
ARG TARGET
LABEL maintainer="BlackDex <[email protected]>"
LABEL org.opencontainers.image.create="$(date --utc --iso-8601=seconds)"
LABEL org.opencontainers.image.documentation="https://github.com/BlackDex/rust-musl/"
LABEL org.opencontainers.image.licenses="Apache License 2.0"
LABEL org.opencontainers.image.url="https://github.com/BlackDex/rust-musl/"
LABEL org.opencontainers.image.description="MUSL Cross Build Toolchain for ${TARGET}"