Skip to content

Commit f546979

Browse files
committed
chore: fix amd64 and arm64 docker images tests
1 parent e5f483d commit f546979

File tree

6 files changed

+90
-63
lines changed

6 files changed

+90
-63
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*
22

3-
!cargo
3+
!docker
44
!Dockerfile
55
!Makefile
66
!scripts

Makefile

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
REPOSITORY ?= joseluisq
22
TAG ?= latest
33

4-
54
build-amd64:
65
docker build \
76
-t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-amd64 \
87
--network=host \
98
-f docker/amd64/Dockerfile .
109
.PHONY: build-amd64
1110

11+
run-amd64:
12+
@docker run --rm -it \
13+
-v $(PWD):/root/src \
14+
-v $(PWD)/docker/amd64/cargo.toml:/root/.cargo/config.toml \
15+
-w /root/src \
16+
$(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-amd64 \
17+
bash
18+
.PHONY: run-amd64
19+
1220
build-arm64:
1321
docker buildx build \
1422
-t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-arm64 \
@@ -17,6 +25,15 @@ build-arm64:
1725
-f docker/arm64/Dockerfile .
1826
.PHONY: build-arm64
1927

28+
run-arm64:
29+
@docker run --rm -it \
30+
-v $(PWD):/root/src \
31+
-v $(PWD)/docker/arm64/cargo.toml:/root/.cargo/config.toml \
32+
-w /root/src \
33+
$(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-arm64 \
34+
bash
35+
.PHONY: run-arm64
36+
2037
# Use to build both arm64 and amd64 images at the same time.
2138
# WARNING! Will automatically push, since multi-platform images are not available locally.
2239
# Use `REPOSITORY` arg to specify which container repository to push the images to.
@@ -32,15 +49,6 @@ buildx:
3249

3350
.PHONY: buildx
3451

35-
run:
36-
@docker run --rm -it \
37-
-v $(PWD):/root/src \
38-
-v $(PWD)/cargo/config.toml:/root/.cargo/config.toml \
39-
-w /root/src \
40-
$(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \
41-
bash
42-
.PHONY: run
43-
4452
test:
4553
@docker run --rm \
4654
-v $(PWD):/root/src \
@@ -59,7 +67,7 @@ test-app:
5967
@cd tests/hello-world \
6068
\
6169
&& echo "Compiling application (linux-gnu x86_64)..." \
62-
&& cargo build --release --target x86_64-unknown-linux-gnu \
70+
&& cargo build -v --release --target x86_64-unknown-linux-gnu \
6371
&& if [ "$$(uname -m)" = "x86_64" ]; then \
6472
target/x86_64-unknown-linux-gnu/release/hello-world-test; \
6573
fi \
@@ -68,7 +76,7 @@ test-app:
6876
&& echo \
6977
\
7078
&& echo "Compiling application (linux-musl x86_64)..." \
71-
&& cargo build --release --target x86_64-unknown-linux-musl \
79+
&& cargo build -v --release --target x86_64-unknown-linux-musl \
7280
&& if [ "$$(uname -m)" = "x86_64" ]; then \
7381
target/x86_64-unknown-linux-musl/release/hello-world-test; \
7482
fi \
@@ -77,13 +85,13 @@ test-app:
7785
&& echo \
7886
\
7987
&& echo "Cross-compiling application (apple-darwin x86_64)..." \
80-
&& cargo build --release --target x86_64-apple-darwin \
88+
&& cargo build -v --release --target x86_64-apple-darwin \
8189
&& du -sh target/x86_64-apple-darwin/release/hello-world-test \
8290
&& file target/x86_64-apple-darwin/release/hello-world-test \
8391
&& echo \
8492
\
8593
&& echo "Cross-compiling application (linux-gnu aarch64)..." \
86-
&& cargo build --release --target aarch64-unknown-linux-gnu \
94+
&& cargo build -v --release --target aarch64-unknown-linux-gnu \
8795
&& if [ "$$(uname -m)" = "aarch64" ]; then \
8896
target/aarch64-unknown-linux-gnu/release/hello-world-test; \
8997
fi \
@@ -92,7 +100,7 @@ test-app:
92100
&& echo \
93101
\
94102
&& echo "Cross-compiling application (linux-musl aarch64)..." \
95-
&& cargo build --release --target aarch64-unknown-linux-musl \
103+
&& cargo build -v --release --target aarch64-unknown-linux-musl \
96104
&& if [ "$$(uname -m)" = "aarch64" ]; then \
97105
target/aarch64-unknown-linux-musl/release/hello-world-test; \
98106
fi \
@@ -101,7 +109,7 @@ test-app:
101109
&& echo \
102110
\
103111
&& echo "Cross-compiling application (apple-darwin aarch64)..." \
104-
&& cargo build --release --target aarch64-apple-darwin \
112+
&& cargo build -v --release --target aarch64-apple-darwin \
105113
&& du -sh target/aarch64-apple-darwin/release/hello-world-test \
106114
&& file target/aarch64-apple-darwin/release/hello-world-test \
107115
&& echo
@@ -117,7 +125,7 @@ test-zlib:
117125
@cd tests/zlib \
118126
\
119127
&& echo "Compiling application (linux-gnu x86_64)..." \
120-
&& cargo build --release --target x86_64-unknown-linux-gnu \
128+
&& cargo build -v --release --target x86_64-unknown-linux-gnu \
121129
&& if [ "$$(uname -m)" = "x86_64" ]; then
122130
target/x86_64-unknown-linux-gnu/release/zlib-test; \
123131
fi \
@@ -126,7 +134,7 @@ test-zlib:
126134
&& echo \
127135
\
128136
&& echo "Compiling application (linux-musl x86_64)..." \
129-
&& cargo build --release --target x86_64-unknown-linux-musl \
137+
&& cargo build -v --release --target x86_64-unknown-linux-musl \
130138
&& if [ "$$(uname -m)" = "x86_64" ]; then
131139
target/x86_64-unknown-linux-musl/release/zlib-test; \
132140
fi \
@@ -136,14 +144,14 @@ test-zlib:
136144
\
137145
&& echo "Cross-compiling application (apple-darwin x86_64)..." \
138146
&& CC=o64-clang CXX=o64-clang++ \
139-
cargo build --release --target x86_64-apple-darwin \
147+
cargo build -v --release --target x86_64-apple-darwin \
140148
&& du -sh target/x86_64-apple-darwin/release/zlib-test \
141149
&& file target/x86_64-apple-darwin/release/zlib-test \
142150
&& echo \
143151
\
144152
&& echo "Cross-compiling application (linux-gnu aarch64)..." \
145153
&& CC=aarch64-linux-gnu-gcc \
146-
cargo build --release --target aarch64-unknown-linux-gnu \
154+
cargo build -v --release --target aarch64-unknown-linux-gnu \
147155
&& if [ "$$(uname -m)" = "aarch64" ]; then \
148156
target/aarch64-unknown-linux-gnu/release/zlib-test; \
149157
fi \
@@ -152,7 +160,7 @@ test-zlib:
152160
&& echo \
153161
\
154162
&& echo "Cross-compiling application (linux-musl aarch64)..." \
155-
&& cargo build --release --target aarch64-unknown-linux-musl \
163+
&& cargo build -v --release --target aarch64-unknown-linux-musl \
156164
&& if [ "$$(uname -m)" = "aarch64" ]; then \
157165
target/aarch64-unknown-linux-musl/release/zlib-test; \
158166
fi \
@@ -162,7 +170,7 @@ test-zlib:
162170
\
163171
&& echo "Cross-compiling application (apple-darwin aarch64)..." \
164172
&& CC=oa64-clang CXX=oa64-clang++ \
165-
cargo build --release --target aarch64-apple-darwin \
173+
cargo build -v --release --target aarch64-apple-darwin \
166174
&& du -sh target/aarch64-apple-darwin/release/zlib-test \
167175
&& file target/aarch64-apple-darwin/release/zlib-test \
168176
&& echo \
@@ -179,7 +187,7 @@ test-openssl:
179187
@cd tests/openssl \
180188
\
181189
&& echo "Compiling application (linux-gnu x86_64)..." \
182-
&& cargo build --release --target x86_64-unknown-linux-gnu \
190+
&& cargo build -v --release --target x86_64-unknown-linux-gnu \
183191
&& if [ "$$(uname -m)" = "x86_64" ]; then \
184192
target/x86_64-unknown-linux-gnu/release/openssl; \
185193
fi \
@@ -189,7 +197,7 @@ test-openssl:
189197
\
190198
&& echo "Cross-compiling application (linux-gnu aarch64)..." \
191199
&& CC=aarch64-linux-gnu-gcc \
192-
cargo build --release --target aarch64-unknown-linux-gnu \
200+
cargo build -v --release --target aarch64-unknown-linux-gnu \
193201
&& if [ "$$(uname -m)" = "aarch64" ]; then \
194202
target/aarch64-unknown-linux-gnu/release/openssl; \
195203
fi \
@@ -199,7 +207,7 @@ test-openssl:
199207
\
200208
&& echo "Compiling application (linux-musl x86_64)..." \
201209
&& OPENSSL_STATIC=1 \
202-
cargo build --release --target x86_64-unknown-linux-musl \
210+
cargo build -v --release --target x86_64-unknown-linux-musl \
203211
&& if [ "$$(uname -m)" = "x86_64" ]; then \
204212
target/x86_64-unknown-linux-musl/release/openssl; \
205213
fi \
@@ -210,14 +218,14 @@ test-openssl:
210218
&& echo "Cross-compiling application (apple-darwin x86_64)..." \
211219
&& OPENSSL_STATIC=1 \
212220
CC=o64-clang CXX=o64-clang++ \
213-
cargo build --release --target x86_64-apple-darwin \
221+
cargo build -v --release --target x86_64-apple-darwin \
214222
&& du -sh target/x86_64-apple-darwin/release/openssl \
215223
&& file target/x86_64-apple-darwin/release/openssl \
216224
&& echo \
217225
\
218226
&& echo "Cross-compiling application (linux-musl aarch64)..." \
219227
&& OPENSSL_STATIC=1 \
220-
cargo build --release --target aarch64-unknown-linux-musl \
228+
cargo build -v --release --target aarch64-unknown-linux-musl \
221229
&& if [ "$$(uname -m)" = "aarch64" ]; then \
222230
target/aarch64-unknown-linux-musl/release/openssl;
223231
fi \
@@ -228,7 +236,7 @@ test-openssl:
228236
&& echo "Cross-compiling application (apple-darwin aarch64)..." \
229237
&& OPENSSL_STATIC=1 \
230238
CC=oa64-clang CXX=oa64-clang++ \
231-
cargo build --release --target aarch64-apple-darwin \
239+
cargo build -v --release --target aarch64-apple-darwin \
232240
&& du -sh target/aarch64-apple-darwin/release/openssl \
233241
&& file target/aarch64-apple-darwin/release/openssl \
234242
&& echo

docker/amd64/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ RUN set -eux \
3737
x86_64-unknown-linux-gnu \
3838
&& true
3939

40-
COPY cargo/config.toml /root/.cargo/config.toml
40+
COPY docker/amd64/cargo.toml /root/.cargo/config.toml
4141

4242
RUN set -eux \
4343
&& rustc -vV \
@@ -259,6 +259,7 @@ ENV PKG_CONFIG_ALL_STATIC=true
259259
# OpenSSL related environment variables
260260
ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1
261261
ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/x86_64-linux-musl
262+
ENV X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR=/usr/local/x86_64-linux-musl
262263
ENV X86_64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/x86_64-apple-darwin
263264

264265
ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1

cargo/config.toml renamed to docker/amd64/cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[build]
2+
23
# Target musl-libc by default when running Cargo
34
target = "x86_64-unknown-linux-musl"
45

56
[target.aarch64-unknown-linux-gnu]
67
linker = "aarch64-linux-gnu-gcc"
78

89
[target.aarch64-unknown-linux-musl]
9-
linker = "aarch64-linux-gnu-gcc"
10+
linker = "aarch64-linux-musl-gcc"
1011

1112
[target.x86_64-apple-darwin]
1213
linker = "x86_64-apple-darwin22.4-clang"

docker/arm64/Dockerfile

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ RUN set -eux \
3737
x86_64-unknown-linux-gnu \
3838
&& true
3939

40-
COPY cargo/config.toml /root/.cargo/config.toml
40+
COPY docker/arm64/cargo.toml /root/.cargo/config.toml
4141

4242
RUN set -eux \
4343
&& rustc -vV \
@@ -200,36 +200,35 @@ RUN set -eux \
200200
&& rm -rf "openssl-${OPENSSL_VERSION}" \
201201
&& true
202202

203-
# TODO:
204-
# RUN set -eux \
205-
# && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \
206-
# && cd "openssl-${OPENSSL_VERSION}" \
207-
# && echo "Building OpenSSL ${OPENSSL_VERSION} for x86_64..." \
208-
# && mkdir -p /usr/local/x86_64-linux-musl/include \
209-
# && ln -s "/usr/include/x86_64-linux-gnu/asm" /usr/local/x86_64-linux-musl/include/asm \
210-
# && env CC=x86_64-linux-musl-gcc \
211-
# ./Configure no-asm no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \
212-
# -fPIC --prefix=/usr/local/x86_64-linux-musl \
213-
# -DOPENSSL_NO_SECURE_MEMORY "linux-x86_64" \
214-
# && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make depend \
215-
# && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make -j$(nproc) \
216-
# && make -j$(nproc) install_sw \
217-
# && make -j$(nproc) install_ssldirs \
218-
# && rm -rf \
219-
# /usr/local/x86_64-linux-musl/include/asm \
220-
# && ls -l /usr/local/x86_64-linux-musl \
221-
# && if ! [ -d /usr/local/x86_64-linux-musl/lib ]; then \
222-
# ln -s /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \
223-
# else \
224-
# mv /usr/local/x86_64-linux-musl/lib /usr/local/x86_64-linux-musl/abc; \
225-
# mv /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \
226-
# cp -rp /usr/local/x86_64-linux-musl/abc/. /usr/local/x86_64-linux-musl/lib/; \
227-
# unlink /usr/local/x86_64-linux-musl/lib/lib64; \
228-
# rm -rf /usr/local/x86_64-linux-musl/abc; \
229-
# fi \
230-
# && cd .. \
231-
# && rm -rf "openssl-${OPENSSL_VERSION}" \
232-
# && true
203+
RUN set -eux \
204+
&& tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \
205+
&& cd "openssl-${OPENSSL_VERSION}" \
206+
&& echo "Building OpenSSL ${OPENSSL_VERSION} for x86_64..." \
207+
&& mkdir -p /usr/local/x86_64-linux-musl/include \
208+
&& ln -s "/usr/include/x86_64-linux-gnu/asm" /usr/local/x86_64-linux-musl/include/asm \
209+
&& env CC=x86_64-linux-musl-gcc \
210+
./Configure no-asm no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \
211+
-fPIC --prefix=/usr/local/x86_64-linux-musl \
212+
-DOPENSSL_NO_SECURE_MEMORY "linux-x86_64" \
213+
&& env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make depend \
214+
&& env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make -j$(nproc) \
215+
&& make -j$(nproc) install_sw \
216+
&& make -j$(nproc) install_ssldirs \
217+
&& rm -rf \
218+
/usr/local/x86_64-linux-musl/include/asm \
219+
&& ls -l /usr/local/x86_64-linux-musl \
220+
&& if ! [ -d /usr/local/x86_64-linux-musl/lib ]; then \
221+
ln -s /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \
222+
else \
223+
mv /usr/local/x86_64-linux-musl/lib /usr/local/x86_64-linux-musl/abc; \
224+
mv /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \
225+
cp -rp /usr/local/x86_64-linux-musl/abc/. /usr/local/x86_64-linux-musl/lib/; \
226+
unlink /usr/local/x86_64-linux-musl/lib/lib64; \
227+
rm -rf /usr/local/x86_64-linux-musl/abc; \
228+
fi \
229+
&& cd .. \
230+
&& rm -rf "openssl-${OPENSSL_VERSION}" \
231+
&& true
233232

234233
RUN set -eux \
235234
&& echo "Testing musl-gcc with OpenSSL..." \
@@ -261,7 +260,7 @@ ENV X86_64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/x86_64-apple-darwin
261260

262261
ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1
263262
ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/aarch64-linux-musl
264-
ENV AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_DIR=/usr/local/aarch64-linux-gnu
263+
ENV AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_DIR=/usr/local/aarch64-linux-musl
265264
ENV AARCH64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/aarch64-apple-darwin
266265

267266
WORKDIR /root/src

docker/arm64/cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[build]
2+
3+
# Target musl-libc by default when running Cargo
4+
target = "aarch64-unknown-linux-musl"
5+
6+
[target.x86_64-unknown-linux-gnu]
7+
linker = "x86_64-linux-gnu-gcc"
8+
9+
[target.x86_64-unknown-linux-musl]
10+
linker = "x86_64-linux-musl-gcc"
11+
12+
[target.x86_64-apple-darwin]
13+
linker = "x86_64-apple-darwin22.4-clang"
14+
ar = "x86_64-apple-darwin22.4-ar"
15+
16+
[target.aarch64-apple-darwin]
17+
linker = "arm64e-apple-darwin22.4-clang"
18+
ar = "arm64e-apple-darwin22.4-ar"

0 commit comments

Comments
 (0)