Docker image of SwiftLint on ubuntu
MIT License
In this document, using amd64, arm64 for platform architecture for docker, and x86_64, aarch64 for Swift architecture.
builder
directorydocker buildx build --load builder/ -t swiftlint
docker buildx build --load builder/ -t swiftlint \
--platform linux/amd64,linux/arm64
BUILDER_IAMGE
using TARGET_IMAGE
as Swift SDKSetup TARGET_IMAGE
as the Swift SDK for the target architecture, and use them from Swift Toolchain in BUILDER_IMAGE
.
Supported combinations of TARGET_IMAGE
and BUILDER_IMAGE
are as follows:
aarch64 builder | x86_64 builder | |
---|---|---|
aarch64 target | aarch64-on-aarch64 | aarch64-on-x86_64 |
x86_64 target | x86_64-on-aarch64 | x86_64-on-x86_64 |
--build-arg USE_SDK=1
for building with Swift SDKBuild arm64 architecture image using Swift SDK (aarch64-on-aarch64)
docker buildx build --load builder/ -t swiftlint \
--platform linux/arm64 --build-arg USE_SDK=1
--build-arg CROSS=1
for cross compilation with Swift SDKBuild arm64 architecture image on amd64 architecture using Swift SDK (aarch64-on-x86_64)
docker buildx build --load builder/ -t swiftlint \
--platform linux/arm64 --build-arg CROSS=1
--build-arg CROSS_TARGETARCHS=...
for cross compiling target architectures with Swift SDKBuild multi-architecture image, native compileed arm64 (aarch64-no-sdk), cross compiled amd64 (x86_64-on-aarch64).
docker buildx build --load builder/ -t swiftlint \
--platform linux/amd64,linux/arm64 --build-arg CROSS_TARGETARCHS=amd64
This command minimizes the use of emulation on arm64 host.
copier
directoryExpected to use swiftlint
binary built in builder
directory.
qemu-user-static
There is a known issue where running an aarch64 executable generated with Swift on x86_64 Ubuntu using the default qemu-user-static
results in a crash.
https://forums.swift.org/t/swift-runtime-unable-to-suspend-thread-when-compiling-in-qemu/67676
This issue can be avoided by using qemu-user-static-7.2 distributed by Debian. There are two methods to install it:
docker run --rm --privileged multiarch/qemu-user-static:7.2.0-1 --reset -p yes
.Norio Nomura
available under the MIT license. See the LICENSE file for more info.