From 23d459df7418969c1023044f19fd004920347a81 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 9 May 2022 02:55:17 +0000 Subject: [PATCH 1/8] feat: build armv7 linux releases --- .goreleaser.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 3cf980383d7ad..0ff07ed93a06d 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -45,7 +45,8 @@ builds: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"] env: [CGO_ENABLED=0] goos: [linux] - goarch: [amd64, arm64] + goarch: [amd64, arm, arm64] + goarm: ["7"] - id: coder-windows dir: cmd/coder From 1cf00af32e4d87c9950c939142711b565d84d4d6 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 10 May 2022 22:36:28 +0000 Subject: [PATCH 2/8] upload ARM binaries to bin --- .goreleaser.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0ff07ed93a06d..e9f9b60736f41 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -32,7 +32,8 @@ builds: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"] env: [CGO_ENABLED=0] goos: [darwin, linux, windows] - goarch: [amd64] + goarch: [amd64, arm, arm64] + goarm: ["7"] hooks: # The "trimprefix" appends ".exe" on Windows. post: | From 812ba593d3a7e08faf5e82ff8d66f754264bd2f2 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 10 May 2022 23:00:20 +0000 Subject: [PATCH 3/8] Only build arm 7 for Linux --- .goreleaser.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index e9f9b60736f41..bdb15a16c432d 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -34,6 +34,12 @@ builds: goos: [darwin, linux, windows] goarch: [amd64, arm, arm64] goarm: ["7"] + # Only build arm 7 for Linux + ignore: + - goos: windows + goarm: '7' + - goos: darwin + goarm: '7' hooks: # The "trimprefix" appends ".exe" on Windows. post: | From 5f3ad60267815322d3edd65a7508d5603d6091c1 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 10 May 2022 23:04:56 +0000 Subject: [PATCH 4/8] add ARM agent scripts --- provisionersdk/agent.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/provisionersdk/agent.go b/provisionersdk/agent.go index baaff0745f431..e701b390c4bd0 100644 --- a/provisionersdk/agent.go +++ b/provisionersdk/agent.go @@ -16,6 +16,12 @@ Invoke-WebRequest -Uri ${ACCESS_URL}bin/coder-windows-amd64.exe -OutFile $env:TE Set-MpPreference -DisableRealtimeMonitoring $true -ExclusionPath $env:TEMP\sshd.exe $env:CODER_AGENT_AUTH = "${AUTH_TYPE}" $env:CODER_AGENT_URL = "${ACCESS_URL}" +Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru`, + "arm64": `$ProgressPreference = "SilentlyContinue" +Invoke-WebRequest -Uri ${ACCESS_URL}bin/coder-windows-arm64.exe -OutFile $env:TEMP\sshd.exe +Set-MpPreference -DisableRealtimeMonitoring $true -ExclusionPath $env:TEMP\sshd.exe +$env:CODER_AGENT_AUTH = "${AUTH_TYPE}" +$env:CODER_AGENT_URL = "${ACCESS_URL}" Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru`, }, "linux": { @@ -26,6 +32,22 @@ curl -fsSL ${ACCESS_URL}bin/coder-linux-amd64 -o $BINARY_LOCATION chmod +x $BINARY_LOCATION export CODER_AGENT_AUTH="${AUTH_TYPE}" export CODER_AGENT_URL="${ACCESS_URL}" +exec $BINARY_LOCATION agent`, + "arm64": `#!/usr/bin/env sh +set -eu pipefail +export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder +curl -fsSL ${ACCESS_URL}bin/coder-linux-arm64 -o $BINARY_LOCATION +chmod +x $BINARY_LOCATION +export CODER_AGENT_AUTH="${AUTH_TYPE}" +export CODER_AGENT_URL="${ACCESS_URL}" +exec $BINARY_LOCATION agent`, + "arm": `#!/usr/bin/env sh +set -eu pipefail +export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder +curl -fsSL ${ACCESS_URL}bin/coder-linux-arm -o $BINARY_LOCATION +chmod +x $BINARY_LOCATION +export CODER_AGENT_AUTH="${AUTH_TYPE}" +export CODER_AGENT_URL="${ACCESS_URL}" exec $BINARY_LOCATION agent`, }, "darwin": { @@ -36,6 +58,14 @@ curl -fsSL ${ACCESS_URL}bin/coder-darwin-amd64 -o $BINARY_LOCATION chmod +x $BINARY_LOCATION export CODER_AGENT_AUTH="${AUTH_TYPE}" export CODER_AGENT_URL="${ACCESS_URL}" +exec $BINARY_LOCATION agent`, + "arm64": `#!/usr/bin/env sh +set -eu pipefail +export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder +curl -fsSL ${ACCESS_URL}bin/coder-darwin-arm64 -o $BINARY_LOCATION +chmod +x $BINARY_LOCATION +export CODER_AGENT_AUTH="${AUTH_TYPE}" +export CODER_AGENT_URL="${ACCESS_URL}" exec $BINARY_LOCATION agent`, }, } From a1b6b658e1d32d849f06880cfb4eb01bf5464aac Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 11 May 2022 00:45:46 +0000 Subject: [PATCH 5/8] fix: specify armv7 to match tf provider --- provisionersdk/agent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provisionersdk/agent.go b/provisionersdk/agent.go index e701b390c4bd0..6e6a5b9050ea1 100644 --- a/provisionersdk/agent.go +++ b/provisionersdk/agent.go @@ -41,7 +41,7 @@ chmod +x $BINARY_LOCATION export CODER_AGENT_AUTH="${AUTH_TYPE}" export CODER_AGENT_URL="${ACCESS_URL}" exec $BINARY_LOCATION agent`, - "arm": `#!/usr/bin/env sh + "armv7": `#!/usr/bin/env sh set -eu pipefail export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder curl -fsSL ${ACCESS_URL}bin/coder-linux-arm -o $BINARY_LOCATION From ceac8a55dfdacad77c527be533da7d56fd3fec43 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 11 May 2022 04:59:05 +0000 Subject: [PATCH 6/8] append arm version to slim builds --- .goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index bdb15a16c432d..29bfb0341c1f5 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -43,7 +43,7 @@ builds: hooks: # The "trimprefix" appends ".exe" on Windows. post: | - cp {{.Path}} site/out/bin/coder-{{ .Os }}-{{ .Arch }}{{ trimprefix .Name "coder" }} + cp {{.Path}} site/out/bin/coder-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ trimprefix .Name "coder" }} - id: coder-linux dir: cmd/coder From 449ef7b564ccbd3809a02087206fa7c5793e4a95 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 11 May 2022 05:01:32 +0000 Subject: [PATCH 7/8] use descript armv7 binary --- provisionersdk/agent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provisionersdk/agent.go b/provisionersdk/agent.go index 6e6a5b9050ea1..a1bc12298e93d 100644 --- a/provisionersdk/agent.go +++ b/provisionersdk/agent.go @@ -44,7 +44,7 @@ exec $BINARY_LOCATION agent`, "armv7": `#!/usr/bin/env sh set -eu pipefail export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder -curl -fsSL ${ACCESS_URL}bin/coder-linux-arm -o $BINARY_LOCATION +curl -fsSL ${ACCESS_URL}bin/coder-linux-armv7 -o $BINARY_LOCATION chmod +x $BINARY_LOCATION export CODER_AGENT_AUTH="${AUTH_TYPE}" export CODER_AGENT_URL="${ACCESS_URL}" From 01d5b508880340493244a5443dc88f8c5a3ef39f Mon Sep 17 00:00:00 2001 From: kylecarbs Date: Wed, 11 May 2022 14:18:19 +0000 Subject: [PATCH 8/8] Add script mappings for each architecture --- provisionersdk/agent.go | 85 +++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 50 deletions(-) diff --git a/provisionersdk/agent.go b/provisionersdk/agent.go index a1bc12298e93d..00f6861ef9136 100644 --- a/provisionersdk/agent.go +++ b/provisionersdk/agent.go @@ -1,72 +1,56 @@ package provisionersdk -import "fmt" +import ( + "fmt" + "strings" +) var ( - // A mapping of operating-system ($GOOS) to architecture ($GOARCH) - // to agent install and run script. ${DOWNLOAD_URL} is replaced - // with strings.ReplaceAll() when being consumed. - agentScripts = map[string]map[string]string{ - // On Windows, VS Code Remote requires a parent process of the - // executing shell to be named "sshd", otherwise it fails. See: - // https://github.com/microsoft/vscode-remote-release/issues/5699 - "windows": { - "amd64": `$ProgressPreference = "SilentlyContinue" -Invoke-WebRequest -Uri ${ACCESS_URL}bin/coder-windows-amd64.exe -OutFile $env:TEMP\sshd.exe + // On Windows, VS Code Remote requires a parent process of the + // executing shell to be named "sshd", otherwise it fails. See: + // https://github.com/microsoft/vscode-remote-release/issues/5699 + windowsScript = `$ProgressPreference = "SilentlyContinue" +Invoke-WebRequest -Uri ${ACCESS_URL}bin/coder-windows-${ARCH}.exe -OutFile $env:TEMP\sshd.exe Set-MpPreference -DisableRealtimeMonitoring $true -ExclusionPath $env:TEMP\sshd.exe $env:CODER_AGENT_AUTH = "${AUTH_TYPE}" $env:CODER_AGENT_URL = "${ACCESS_URL}" -Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru`, - "arm64": `$ProgressPreference = "SilentlyContinue" -Invoke-WebRequest -Uri ${ACCESS_URL}bin/coder-windows-arm64.exe -OutFile $env:TEMP\sshd.exe -Set-MpPreference -DisableRealtimeMonitoring $true -ExclusionPath $env:TEMP\sshd.exe -$env:CODER_AGENT_AUTH = "${AUTH_TYPE}" -$env:CODER_AGENT_URL = "${ACCESS_URL}" -Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru`, - }, - "linux": { - "amd64": `#!/usr/bin/env sh -set -eu pipefail -export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder -curl -fsSL ${ACCESS_URL}bin/coder-linux-amd64 -o $BINARY_LOCATION -chmod +x $BINARY_LOCATION -export CODER_AGENT_AUTH="${AUTH_TYPE}" -export CODER_AGENT_URL="${ACCESS_URL}" -exec $BINARY_LOCATION agent`, - "arm64": `#!/usr/bin/env sh +Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru` + + linuxScript = `#!/usr/bin/env sh set -eu pipefail export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder -curl -fsSL ${ACCESS_URL}bin/coder-linux-arm64 -o $BINARY_LOCATION +curl -fsSL ${ACCESS_URL}bin/coder-linux-${ARCH} -o $BINARY_LOCATION chmod +x $BINARY_LOCATION export CODER_AGENT_AUTH="${AUTH_TYPE}" export CODER_AGENT_URL="${ACCESS_URL}" -exec $BINARY_LOCATION agent`, - "armv7": `#!/usr/bin/env sh +exec $BINARY_LOCATION agent` + + darwinScript = `#!/usr/bin/env sh set -eu pipefail export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder -curl -fsSL ${ACCESS_URL}bin/coder-linux-armv7 -o $BINARY_LOCATION +curl -fsSL ${ACCESS_URL}bin/coder-darwin-${ARCH} -o $BINARY_LOCATION chmod +x $BINARY_LOCATION export CODER_AGENT_AUTH="${AUTH_TYPE}" export CODER_AGENT_URL="${ACCESS_URL}" -exec $BINARY_LOCATION agent`, +exec $BINARY_LOCATION agent` + + // A mapping of operating-system ($GOOS) to architecture ($GOARCH) + // to agent install and run script. ${DOWNLOAD_URL} is replaced + // with strings.ReplaceAll() when being consumed. ${ARCH} is replaced + // with the architecture when being provided. + agentScripts = map[string]map[string]string{ + "windows": { + "amd64": windowsScript, + "arm64": windowsScript, + }, + "linux": { + "amd64": linuxScript, + "arm64": linuxScript, + "armv7": linuxScript, }, "darwin": { - "amd64": `#!/usr/bin/env sh -set -eu pipefail -export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder -curl -fsSL ${ACCESS_URL}bin/coder-darwin-amd64 -o $BINARY_LOCATION -chmod +x $BINARY_LOCATION -export CODER_AGENT_AUTH="${AUTH_TYPE}" -export CODER_AGENT_URL="${ACCESS_URL}" -exec $BINARY_LOCATION agent`, - "arm64": `#!/usr/bin/env sh -set -eu pipefail -export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder -curl -fsSL ${ACCESS_URL}bin/coder-darwin-arm64 -o $BINARY_LOCATION -chmod +x $BINARY_LOCATION -export CODER_AGENT_AUTH="${AUTH_TYPE}" -export CODER_AGENT_URL="${ACCESS_URL}" -exec $BINARY_LOCATION agent`, + "amd64": darwinScript, + "arm64": darwinScript, }, } ) @@ -78,6 +62,7 @@ func AgentScriptEnv() map[string]string { env := map[string]string{} for operatingSystem, scripts := range agentScripts { for architecture, script := range scripts { + script := strings.ReplaceAll(script, "${ARCH}", architecture) env[fmt.Sprintf("CODER_AGENT_SCRIPT_%s_%s", operatingSystem, architecture)] = script } }