Skip to content

Commit 3b15234

Browse files
authored
chore: add continuous deployment for workspace proxies (#7364)
1 parent 4b9621f commit 3b15234

File tree

9 files changed

+61
-14
lines changed

9 files changed

+61
-14
lines changed

.github/workflows/ci.yaml

+19-6
Original file line numberDiff line numberDiff line change
@@ -487,14 +487,27 @@ jobs:
487487
488488
- name: Install Release
489489
run: |
490+
set -euo pipefail
491+
492+
regions=(
493+
# gcp-region-id instance-name systemd-service-name
494+
"us-central1-a coder coder"
495+
"australia-southeast1-b coder-sydney coder-proxy"
496+
"europe-west3-c coder-europe coder-proxy"
497+
"southamerica-east1-b coder-brazil coder-proxy"
498+
)
499+
490500
gcloud config set project coder-dogfood
491-
gcloud config set compute/zone us-central1-a
492-
gcloud compute scp ./build/coder_*_linux_amd64.deb coder:/tmp/coder.deb
493-
gcloud compute ssh coder -- sudo dpkg -i --force-confdef /tmp/coder.deb
494-
gcloud compute ssh coder -- sudo systemctl daemon-reload
501+
for region in "${regions[@]}"; do
502+
echo "::group::$region"
503+
set -- $region
504+
505+
gcloud config set compute/zone "$1"
506+
gcloud compute scp ./build/coder_*_linux_amd64.deb "$2":/tmp/coder.deb
507+
gcloud compute ssh "$2" -- /bin/sh -c "set -eux; sudo dpkg -i --force-confdef /tmp/coder.deb; sudo systemctl daemon-reload; sudo service '$3' restart"
495508
496-
- name: Start
497-
run: gcloud compute ssh coder -- sudo service coder restart
509+
echo "::endgroup::"
510+
done
498511
499512
- uses: actions/upload-artifact@v3
500513
with:

codersdk/workspaceproxy.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ type WorkspaceProxyStatus struct {
3939
// A healthy report will have no errors. Warnings are not fatal.
4040
type ProxyHealthReport struct {
4141
// Errors are problems that prevent the workspace proxy from being healthy
42-
Errors []string
42+
Errors []string `json:"errors"`
4343
// Warnings do not prevent the workspace proxy from being healthy, but
4444
// should be addressed.
45-
Warnings []string
45+
Warnings []string `json:"warnings"`
4646
}
4747

4848
type WorkspaceProxy struct {

enterprise/wsproxy/wsproxy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func New(ctx context.Context, opts *Options) (*Server, error) {
229229
s.AppServer.Attach(r)
230230
})
231231

232-
r.Get("/buildinfo", s.buildInfo)
232+
r.Get("/api/v2/buildinfo", s.buildInfo)
233233
r.Get("/healthz", func(w http.ResponseWriter, r *http.Request) { _, _ = w.Write([]byte("OK")) })
234234
// TODO: @emyrk should this be authenticated or debounced?
235235
r.Get("/healthz-report", s.healthReport)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[Unit]
2+
Description="Coder - external workspace proxy server"
3+
Documentation=https://coder.com/docs/coder-oss
4+
Requires=network-online.target
5+
After=network-online.target
6+
ConditionFileNotEmpty=/etc/coder.d/coder-proxy.env
7+
StartLimitIntervalSec=60
8+
StartLimitBurst=3
9+
10+
[Service]
11+
Type=notify
12+
EnvironmentFile=/etc/coder.d/coder-proxy.env
13+
User=coder
14+
Group=coder
15+
ProtectSystem=full
16+
PrivateTmp=yes
17+
PrivateDevices=yes
18+
SecureBits=keep-caps
19+
AmbientCapabilities=CAP_IPC_LOCK CAP_NET_BIND_SERVICE
20+
CacheDirectory=coder
21+
CapabilityBoundingSet=CAP_SYSLOG CAP_IPC_LOCK CAP_NET_BIND_SERVICE
22+
KillSignal=SIGINT
23+
KillMode=mixed
24+
NoNewPrivileges=yes
25+
ExecStart=/usr/bin/coder proxy server
26+
Restart=on-failure
27+
RestartSec=5
28+
TimeoutStopSec=90
29+
30+
[Install]
31+
WantedBy=multi-user.target
File renamed without changes.

scripts/nfpm.yaml renamed to scripts/linux-pkg/nfpm.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ contents:
2525
type: "config|noreplace"
2626
- src: coder.service
2727
dst: /usr/lib/systemd/system/coder.service
28+
- src: coder-proxy.service
29+
dst: /usr/lib/systemd/system/coder-proxy.service
File renamed without changes.

scripts/package.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ cdroot
8484
temp_dir="$(TMPDIR="$(dirname "$input_file")" mktemp -d)"
8585
ln "$input_file" "$temp_dir/coder"
8686
ln "$(realpath coder.env)" "$temp_dir/"
87-
ln "$(realpath coder.service)" "$temp_dir/"
88-
ln "$(realpath preinstall.sh)" "$temp_dir/"
89-
ln "$(realpath scripts/nfpm.yaml)" "$temp_dir/"
87+
ln "$(realpath scripts/linux-pkg/coder-workspace-proxy.service)" "$temp_dir/"
88+
ln "$(realpath scripts/linux-pkg/coder.service)" "$temp_dir/"
89+
ln "$(realpath scripts/linux-pkg/nfpm.yaml)" "$temp_dir/"
90+
ln "$(realpath scripts/linux-pkg/preinstall.sh)" "$temp_dir/"
9091

9192
pushd "$temp_dir"
9293
GOARCH="$arch" CODER_VERSION="$version" nfpm package \

site/src/api/typesGenerated.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,8 @@ export interface ProvisionerJobLog {
692692

693693
// From codersdk/workspaceproxy.go
694694
export interface ProxyHealthReport {
695-
readonly Errors: string[]
696-
readonly Warnings: string[]
695+
readonly errors: string[]
696+
readonly warnings: string[]
697697
}
698698

699699
// From codersdk/workspaces.go

0 commit comments

Comments
 (0)