Skip to content

Commit

Permalink
Add Linux docker setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ileitch committed Dec 26, 2024
1 parent 00c9259 commit 9ab3b1d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git/
.build/
.swiftpm/
.release/
bazel-*
docker/
7 changes: 7 additions & 0 deletions .mise/tasks/scan-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -e

export DOCKER_CLI_HINTS=false
docker build -t periphery -f docker/Dockerfile.linux .
docker run --rm -t periphery scan "$@"
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var dependencies: [Package.Dependency] = [
.package(url: "https://github.com/jpsim/Yams", from: "5.0.0"),
.package(url: "https://github.com/tadija/AEXML", from: "4.0.0"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
.package(url: "https://github.com/kateinoigakukun/swift-indexstore", from: "0.3.0"),
.package(url: "https://github.com/ileitch/swift-indexstore", revision: "a8a375fa31d7f861a8ee44a4d3acab9ecaf742ea"),
.package(url: "https://github.com/apple/swift-syntax", from: "600.0.1"),
.package(url: "https://github.com/ileitch/swift-filename-matcher", from: "2.0.0"),
]
Expand Down
20 changes: 14 additions & 6 deletions Sources/Shared/Shell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ open class Shell {

process.launch()

var stdout = ""
var stderr = ""
var standardOutput = ""
var standardError = ""

if let stdoutData = try stdoutPipe?.fileHandleForReading.readToEnd() {
guard let stdoutStr = String(data: stdoutData, encoding: .utf8)
Expand All @@ -90,7 +90,7 @@ open class Shell {
encoding: .utf8
)
}
stdout = stdoutStr
standardOutput = stdoutStr
}

if let stderrData = try stderrPipe?.fileHandleForReading.readToEnd() {
Expand All @@ -102,11 +102,19 @@ open class Shell {
encoding: .utf8
)
}
stderr = stderrStr
standardError = stderrStr
}

process.waitUntilExit()
#if os(Linux)
// Workaround for https://github.com/swiftlang/swift-corelibs-foundation/issues/5153
let semaphore = DispatchSemaphore(value: 0)
process.terminationHandler = { _ in semaphore.signal() }
semaphore.wait()
#else
process.waitUntilExit()
#endif

ShellProcessStore.shared.remove(process)
return (process.terminationStatus, stdout, stderr)
return (process.terminationStatus, standardOutput, standardError)
}
}
5 changes: 5 additions & 0 deletions docker/Dockerfile.linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM swift:6.0
WORKDIR /workspace
COPY . /workspace
RUN swift build --product periphery
ENTRYPOINT [".build/debug/periphery"]

0 comments on commit 9ab3b1d

Please sign in to comment.