Skip to content

Commit aca29cb

Browse files
committed
fix: add multi-architecture build support using TARGETPLATFORM in Dockerfile
1 parent 1ef648c commit aca29cb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# syntax=docker/dockerfile:1
22

33
# Base image and static SDK have to be updated together.
4-
FROM swift:6.1 AS builder
4+
# Use TARGETPLATFORM to force correct architecture
5+
ARG TARGETPLATFORM
6+
FROM --platform=${TARGETPLATFORM} swift:6.1 AS builder
57
WORKDIR /workspace
68

79
# Install Swift static SDK for better portability
@@ -13,7 +15,12 @@ RUN swift sdk install \
1315
COPY . /workspace
1416

1517
# Build with static SDK using native compilation
16-
RUN swift build -c release --swift-sdk swift-6.1-RELEASE_static-linux-0.0.1 && \
18+
ARG TARGETPLATFORM
19+
RUN echo "=== Build Info ===" && \
20+
echo "TARGETPLATFORM: ${TARGETPLATFORM}" && \
21+
echo "Architecture: $(uname -m)" && \
22+
echo "==================" && \
23+
swift build -c release --swift-sdk swift-6.1-RELEASE_static-linux-0.0.1 && \
1724
find /workspace/.build -name "subtree" -type f -executable -exec cp {} /workspace/subtree \;
1825

1926
# Final minimal runtime image

0 commit comments

Comments
 (0)