-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.base
More file actions
195 lines (180 loc) · 4.89 KB
/
Dockerfile.base
File metadata and controls
195 lines (180 loc) · 4.89 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
ARG ALPINE_VERSION="3.18"
ARG OSX_SDK="MacOSX15.0.sdk"
ARG OSX_SDK_URL="https://github.com/joseluisq/macosx-sdks/releases/download/15.0/${OSX_SDK}.tar.xz"
ARG OSX_CROSS_COMMIT="29fe6dd35522073c9df5800f8cd1feb4b9a993a8"
ARG CROSSTOOL_REPO_REF="6431c800036565af4264fd4bf3f50834fa14452b"
# Get the macOS SDK
FROM alpine:${ALPINE_VERSION} AS sdk
RUN apk --update --no-cache add ca-certificates curl tar xz
ARG OSX_SDK
ARG OSX_SDK_URL
RUN curl -sSL "$OSX_SDK_URL" -o "/$OSX_SDK.tar.xz"
RUN mkdir /osxsdk && tar -xf "/$OSX_SDK.tar.xz" -C "/osxsdk"
# Get the osxcross source
FROM alpine:${ALPINE_VERSION} AS osxcross-src
RUN apk --update --no-cache add patch git
WORKDIR /osxcross
ARG OSX_CROSS_COMMIT
RUN git clone 'https://github.com/tpoechtrager/osxcross.git' /osxcross && \
cd /osxcross && \
git checkout --progress --force $OSX_CROSS_COMMIT && \
git submodule update --init --recursive
# Patch osxcross -- from https://github.com/crazy-max/docker-osxcross
COPY support/lcxx.patch /lcxx.patch
RUN pwd && ls -1al && patch -p1 < /lcxx.patch
# Pre-create the base image using existing macos-cross-compiler
FROM ghcr.io/shepherdjerred/macos-cross-compiler:latest AS base-macoscompilers
# Fix permissions on /tmp
RUN chmod 1777 /tmp
# Install required packages
RUN export DEBIAN_FRONTEND="noninteractive" \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
apt-transport-https \
autoconf \
automake \
bash \
binutils-multiarch-dev \
bison \
build-essential \
ca-certificates \
clang \
cmake \
cpio \
curl \
flex \
gawk \
genisoimage \
git \
gperf \
help2man \
libbz2-dev \
libc6-dev \
libgmp-dev \
liblzma-dev \
libmpc-dev \
libmpfr-dev \
libncurses-dev \
libpsi3-dev \
libssl-dev \
libtool \
libtool-bin \
libxml2-dev \
libz-dev \
libzstd-dev \
lld \
lzma-dev \
make \
meson \
osslsigncode \
patch \
patchelf \
python3 \
rsync \
sudo \
texinfo \
unzip \
uuid-dev \
wget \
xz-utils \
zlib1g-dev \
zip \
zstd \
&& apt-get clean \
&& rm -rf /var/cache/apt/archives /var/lib/apt/lists
# Build binutils for both x86_64 and aarch64
FROM base-macoscompilers AS build-osxcross
ARG OSX_SDK
# Need to reside inside `/tmp/osxcross-gcc-src` as that's where osxcross was previously built, and the environment application outputs that path
WORKDIR /tmp/osxcross-gcc-src
COPY --link --from=osxcross-src /osxcross /tmp/osxcross-gcc-src
COPY --link --from=sdk /$OSX_SDK.tar.xz ./tarballs/$OSX_SDK.tar.xz
ENV PATH="/osxcross/bin:$PATH"
RUN mkdir build
RUN OSX_VERSION_MIN=10.13 UNATTENDED=1 ENABLE_COMPILER_RT_INSTALL=1 TARGET_DIR=/osxcross TARGET_ARCH=x86_64 ./build_binutils.sh
RUN OSX_VERSION_MIN=10.13 UNATTENDED=1 ENABLE_COMPILER_RT_INSTALL=1 TARGET_DIR=/osxcross TARGET_ARCH=aarch64 ./build_binutils.sh
# Build crosstool-ng
FROM build-osxcross AS build-crosstool-ng
ARG CROSSTOOL_REPO_REF
RUN git clone https://github.com/crosstool-ng/crosstool-ng.git /tmp/crosstool-ng \
&& cd /tmp/crosstool-ng \
&& git checkout --progress --force $CROSSTOOL_REPO_REF \
&& ./bootstrap \
&& ./configure --prefix=/ct-ng \
&& make -j$(nproc) \
&& make install
# Final image
FROM ubuntu:noble AS final
RUN export DEBIAN_FRONTEND="noninteractive" \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
apt-transport-https \
autoconf \
automake \
bash \
binutils-multiarch-dev \
bison \
build-essential \
ca-certificates \
clang \
cmake \
cpio \
curl \
flex \
gawk \
genisoimage \
git \
gperf \
help2man \
libbz2-dev \
libc6-dev \
libgmp-dev \
liblzma-dev \
libmpc-dev \
libmpfr-dev \
libncurses-dev \
libpsi3-dev \
libssl-dev \
libtool \
libtool-bin \
libxml2-dev \
libz-dev \
libzstd-dev \
lld \
lzma-dev \
make \
meson \
osslsigncode \
patch \
patchelf \
pkg-config \
python3 \
rsync \
sudo \
texinfo \
unzip \
uuid-dev \
wget \
xz-utils \
zlib1g-dev \
zip \
zstd \
&& apt-get clean \
&& rm -rf /var/cache/apt/archives /var/lib/apt/lists
# Copy across the base image compilers and SDKs
COPY --from=build-crosstool-ng /ct-ng /ct-ng
COPY --from=build-crosstool-ng /osxcross /osxcross
COPY --from=build-crosstool-ng /gcc /gcc
COPY --from=build-crosstool-ng /cctools /cctools
COPY --from=build-crosstool-ng /sdk /sdk
COPY --from=build-crosstool-ng /usr/local /usr/local
# Remove the ubuntu user and group
USER 0:0
RUN userdel ubuntu || true && groupdel ubuntu || true
# Ensure search paths for libraries are up to date
RUN rm /etc/ld.so.cache && ldconfig
# Runtime shell init script to ensure the user is created with the correct UID/GID for the mountpoint
COPY support/init.sh /init.sh
RUN chmod +x /init.sh
ENTRYPOINT ["/init.sh"]
CMD ["bash"]