From e02674e75c62bf7dde6f01563801b72e789bf740 Mon Sep 17 00:00:00 2001 From: Ian Leitch Date: Thu, 19 Dec 2024 19:23:18 +0000 Subject: [PATCH] Add Linux docker setup --- .dockerignore | 6 ++++++ .mise/tasks/scan-linux | 7 +++++++ Sources/Shared/Shell.swift | 10 +++++----- docker/Dockerfile.linux | 5 +++++ 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 .dockerignore create mode 100755 .mise/tasks/scan-linux create mode 100644 docker/Dockerfile.linux diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..6dd2e713d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git/ +.build/ +.swiftpm/ +.release/ +bazel-* +docker/ diff --git a/.mise/tasks/scan-linux b/.mise/tasks/scan-linux new file mode 100755 index 000000000..3bd3bde9a --- /dev/null +++ b/.mise/tasks/scan-linux @@ -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 "$@" diff --git a/Sources/Shared/Shell.swift b/Sources/Shared/Shell.swift index d7a302e0a..cd5e705c5 100644 --- a/Sources/Shared/Shell.swift +++ b/Sources/Shared/Shell.swift @@ -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) @@ -90,7 +90,7 @@ open class Shell { encoding: .utf8 ) } - stdout = stdoutStr + standardOutput = stdoutStr } if let stderrData = try stderrPipe?.fileHandleForReading.readToEnd() { @@ -102,11 +102,11 @@ open class Shell { encoding: .utf8 ) } - stderr = stderrStr + standardError = stderrStr } process.waitUntilExit() ShellProcessStore.shared.remove(process) - return (process.terminationStatus, stdout, stderr) + return (process.terminationStatus, standardOutput, standardError) } } diff --git a/docker/Dockerfile.linux b/docker/Dockerfile.linux new file mode 100644 index 000000000..045deace2 --- /dev/null +++ b/docker/Dockerfile.linux @@ -0,0 +1,5 @@ +FROM swift:latest +WORKDIR /workspace +COPY . /workspace +RUN swift build --product periphery +ENTRYPOINT [".build/debug/periphery"]