Run linux container with same architechture as host
As the development team uses both Intel and Apple Silicon Macs, we have to get the host CPU architecture at compilation time instead of harcoding it. If the container has a different architecture, the guest has to be emulated.
This commit is contained in:
committed by
T. R. Bernstein
parent
4b28c293cb
commit
ac1c86c431
9
Sources/TaskCLI/Docker.swift
Normal file
9
Sources/TaskCLI/Docker.swift
Normal file
@@ -0,0 +1,9 @@
|
||||
struct Docker {
|
||||
static func getLinuxPlatformStringWithHostArchitecture() -> String {
|
||||
#if arch(x86_64)
|
||||
return "linux/amd64"
|
||||
#else
|
||||
return "linux/arm64"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ struct GenerateDocumentationCommand: Script {
|
||||
try await docker(
|
||||
"run", "--rm",
|
||||
"-v", "\(tempDirectory.path):/code",
|
||||
"--platform", "linux/arm64",
|
||||
"--platform", Docker.getLinuxPlatformStringWithHostArchitecture(),
|
||||
"-w", "/code",
|
||||
"swift:latest",
|
||||
"/bin/bash", "-c", script,
|
||||
|
||||
@@ -26,7 +26,7 @@ struct TestCommand: Script {
|
||||
"run",
|
||||
"-v", "\(currentDirectory):/code",
|
||||
"--security-opt", "systempaths=unconfined",
|
||||
"--platform", "linux/arm64",
|
||||
"--platform", Docker.getLinuxPlatformStringWithHostArchitecture(),
|
||||
"-w", "/code", "swift:latest",
|
||||
"/bin/bash", "-c", "swift test --skip InotifyLimitTests; swift test --skip-build --filter InotifyLimitTests"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user