-
Notifications
You must be signed in to change notification settings - Fork 639
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use static Linux SDK in Dockerfile (#1915)
- Loading branch information
1 parent
8991c57
commit 63e8aff
Showing
5 changed files
with
79 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Dockerfile | ||
.dockerignore | ||
.git | ||
.github | ||
.gitignore | ||
|
||
# Everything from .gitignore | ||
# OS X | ||
.DS_Store | ||
|
||
# Xcode | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.dot | ||
.build | ||
.swiftpm | ||
|
||
/Snapshots/Private | ||
swiftformat.artifactbundle.zip | ||
|
||
# AppCode | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
# Swift official image with arm64 support | ||
# https://hub.docker.com/r/arm64v8/swift/ | ||
ARG SWIFT_IMAGE=swift:focal | ||
# Base image and static SDK have to be updated together. | ||
FROM --platform=$BUILDPLATFORM swift:6.0.1 AS builder | ||
WORKDIR /workspace | ||
RUN swift sdk install \ | ||
https://download.swift.org/swift-6.0.1-release/static-sdk/swift-6.0.1-RELEASE/swift-6.0.1-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz \ | ||
--checksum d4f46ba40e11e697387468e18987ee622908bc350310d8af54eb5e17c2ff5481 | ||
|
||
FROM $SWIFT_IMAGE AS builder | ||
COPY . /workspace | ||
WORKDIR /workspace | ||
RUN swift build -c release && mv `swift build -c release --show-bin-path`/swiftformat /workspace | ||
ARG TARGETPLATFORM | ||
RUN --mount=type=cache,target=/workspace/.build,id=build-$TARGETPLATFORM \ | ||
./Scripts/build-linux-release.sh && \ | ||
cp /workspace/.build/release/swiftformat /workspace | ||
|
||
FROM $SWIFT_IMAGE-slim AS runner | ||
COPY --from=builder /workspace/swiftformat /usr/bin | ||
ENTRYPOINT [ "swiftformat" ] | ||
FROM scratch AS runner | ||
COPY --from=builder /workspace/swiftformat /usr/bin/swiftformat | ||
ENTRYPOINT [ "/usr/bin/swiftformat" ] | ||
CMD ["."] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
pushd "$(dirname "${BASH_SOURCE[0]}")/.." > /dev/null | ||
|
||
BUILD_ARGS=( | ||
--product swiftformat | ||
--configuration release | ||
) | ||
|
||
if [[ -z "$TARGETPLATFORM" ]]; then | ||
ARCH="$(uname -m)" | ||
else | ||
if [[ "$TARGETPLATFORM" = "linux/amd64" ]]; then | ||
ARCH="x86_64" | ||
elif [[ "$TARGETPLATFORM" = "linux/arm64" ]]; then | ||
ARCH="aarch64" | ||
else | ||
echo "Unsupported target platform: $TARGETPLATFORM" | ||
exit 1 | ||
fi | ||
fi | ||
BUILD_ARGS+=(--swift-sdk "${ARCH}-swift-linux-musl") | ||
|
||
swift build "${BUILD_ARGS[@]}" |