Skip to content

Commit 9cc2f51

Browse files
committed
refactor: simplify Docker build by removing cross-compilation and using native build only
1 parent 3a3ca7f commit 9cc2f51

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

Dockerfile

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

33
# Base image and static SDK have to be updated together.
4-
FROM --platform=$BUILDPLATFORM swift:6.1 AS builder
4+
FROM swift:6.1 AS builder
55
WORKDIR /workspace
66

77
# Install Swift static SDK for better portability
@@ -12,21 +12,9 @@ RUN swift sdk install \
1212
# Copy source files
1313
COPY . /workspace
1414

15-
# Build with static SDK and cross-compilation support
16-
ARG TARGETPLATFORM
17-
RUN --mount=type=cache,target=/workspace/.build,id=build-$TARGETPLATFORM \
18-
echo "Building for platform: $TARGETPLATFORM" && \
19-
swift sdk list && \
20-
case "$TARGETPLATFORM" in \
21-
"linux/amd64") \
22-
swift build -c release --swift-sdk swift-6.1-RELEASE_static-linux-0.0.1 && \
23-
cp /workspace/.build/*/release/subtree /workspace/subtree ;; \
24-
"linux/arm64") \
25-
swift build -c release --swift-sdk swift-6.1-RELEASE_static-linux-0.0.1 && \
26-
cp /workspace/.build/*/release/subtree /workspace/subtree ;; \
27-
*) \
28-
echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \
29-
esac
15+
# Build with static SDK using native compilation
16+
RUN swift build -c release --swift-sdk swift-6.1-RELEASE_static-linux-0.0.1 && \
17+
find /workspace/.build -name "subtree" -type f -executable -exec cp {} /workspace/subtree \;
3018

3119
# Final minimal runtime image
3220
FROM scratch AS runner

0 commit comments

Comments
 (0)