From da4b9bc7ec27cfb7c27604e50f7d756e66ce95fa Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 1 Dec 2023 13:21:58 +0300 Subject: [PATCH 01/12] chore: add deployment of fly.io workspace proxies --- .github/workflows/ci.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 476f8bad9180a..be6f620cb0b0e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -482,6 +482,27 @@ jobs: ./build/*.deb retention-days: 7 + deploy-wsproxies: + runs-on: ubuntu-latest + needs: build-main-image + if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup flyctl + uses: superfly/flyctl-actions/setup-flyctl@master + + - name: Deploy workspace proxies + run: | + flyctl deploy --image ghcr.io/coder/coder-preview:main --app paris-coder -y + flyctl deploy --image ghcr.io/coder/coder-preview:main --app sydney-coder -y + flyctl deploy --image ghcr.io/coder/coder-preview:main --app sao-paulo-coder -y + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} + test-js: runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} needs: changes @@ -772,6 +793,9 @@ jobs: docker tag ghcr.io/coder/coder-preview:main ghcr.io/coder/coder-preview:main-$tag docker push ghcr.io/coder/coder-preview:main-$tag + # save the image as output + echo "image=ghcr.io/coder/coder-preview:main-$tag" >> $GITHUB_ENV + - name: Prune old images uses: vlaurin/action-ghcr-prune@v0.5.0 with: From 7447ad011d83e9bf3b48f03f27498eb3af21418b Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 1 Dec 2023 13:27:13 +0300 Subject: [PATCH 02/12] remove image output --- .github/workflows/ci.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index be6f620cb0b0e..b09a537f68add 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -793,9 +793,6 @@ jobs: docker tag ghcr.io/coder/coder-preview:main ghcr.io/coder/coder-preview:main-$tag docker push ghcr.io/coder/coder-preview:main-$tag - # save the image as output - echo "image=ghcr.io/coder/coder-preview:main-$tag" >> $GITHUB_ENV - - name: Prune old images uses: vlaurin/action-ghcr-prune@v0.5.0 with: From 54e0fd0b94cdb226cadb7f9615b5c9ed768a53d7 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 1 Dec 2023 13:32:21 +0300 Subject: [PATCH 03/12] test --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b09a537f68add..83e81abc57ff3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -485,7 +485,8 @@ jobs: deploy-wsproxies: runs-on: ubuntu-latest needs: build-main-image - if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork + # if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork + # uncomment the above line after verifying that the workflow works as expected steps: - name: Checkout uses: actions/checkout@v4 From 3a481dffc7805c3365abdea2658aa63597c61f9b Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 1 Dec 2023 13:32:59 +0300 Subject: [PATCH 04/12] test --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 83e81abc57ff3..89eba4b8d9e49 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -746,7 +746,8 @@ jobs: # This build and publihes ghcr.io/coder/coder-preview:main for each merge commit to main branch. # We are only building this for amd64 plateform. (>95% pulls are for amd64) needs: changes - if: github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false' + # if: github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false' + # uncomment the above line after verifying that the workflow works as expected runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} env: DOCKER_CLI_EXPERIMENTAL: "enabled" From 5e35de42b4f6f0e99d1a19477f57b601e6c6831c Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 1 Dec 2023 13:39:29 +0300 Subject: [PATCH 05/12] remove extra condition --- .github/workflows/ci.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 89eba4b8d9e49..fc27984710037 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -485,8 +485,6 @@ jobs: deploy-wsproxies: runs-on: ubuntu-latest needs: build-main-image - # if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork - # uncomment the above line after verifying that the workflow works as expected steps: - name: Checkout uses: actions/checkout@v4 From 6dfc2e78ff9fa78beacf1c73a822ccafcc5175d9 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 1 Dec 2023 13:46:09 +0300 Subject: [PATCH 06/12] ready --- .github/workflows/ci.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fc27984710037..4c214f959f3b0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -744,8 +744,7 @@ jobs: # This build and publihes ghcr.io/coder/coder-preview:main for each merge commit to main branch. # We are only building this for amd64 plateform. (>95% pulls are for amd64) needs: changes - # if: github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false' - # uncomment the above line after verifying that the workflow works as expected + if: github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false' runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} env: DOCKER_CLI_EXPERIMENTAL: "enabled" From f86f238abb1fee25847357818ed0096e0657ded7 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 1 Dec 2023 14:30:47 +0300 Subject: [PATCH 07/12] do not run on forks --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cb83ba9ba252e..030f5a1ea06a3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -770,7 +770,8 @@ jobs: deploy-wsproxies: runs-on: ubuntu-latest - needs: build-main-image + needs: build + if: !github.event.pull_request.head.repo.fork steps: - name: Checkout uses: actions/checkout@v4 From 0057b72103f112902e57819fcce8c4e5a7eee5b8 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Mon, 4 Dec 2023 00:04:54 +0300 Subject: [PATCH 08/12] add configs for fly proxies --- .github/fly-wsproxies/paris-coder.toml | 28 ++++++++++++++++++++++ .github/fly-wsproxies/sao-paulo-coder.toml | 28 ++++++++++++++++++++++ .github/fly-wsproxies/sydney-coder.toml | 28 ++++++++++++++++++++++ .github/workflows/ci.yaml | 21 +++++++++++----- 4 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 .github/fly-wsproxies/paris-coder.toml create mode 100644 .github/fly-wsproxies/sao-paulo-coder.toml create mode 100644 .github/fly-wsproxies/sydney-coder.toml diff --git a/.github/fly-wsproxies/paris-coder.toml b/.github/fly-wsproxies/paris-coder.toml new file mode 100644 index 0000000000000..5178385a5ee15 --- /dev/null +++ b/.github/fly-wsproxies/paris-coder.toml @@ -0,0 +1,28 @@ +app = "paris-coder" +primary_region = "cdg" + +[experimental] + entrypoint = ["/opt/coder", "wsproxy", "server"] + auto_rollback = true + +[build] + image = "ghcr.io/coder/coder-preview:main" + +[env] + CODER_ACCESS_URL = "https://paris-coder.fly.dev" + CODER_HTTP_ADDRESS = "0.0.0.0:3000" + CODER_PRIMARY_ACCESS_URL = "https://dev.coder.com" + CODER_TELEMETRY_INSTALL_SOURCE = "fly.io" + PRIMARY_REGION = "cdg" + +[http_service] + internal_port = 3000 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + +[[vm]] + cpu_kind = "shared" + cpus = 1 + memory_mb = 512 diff --git a/.github/fly-wsproxies/sao-paulo-coder.toml b/.github/fly-wsproxies/sao-paulo-coder.toml new file mode 100644 index 0000000000000..9f620f1bc9915 --- /dev/null +++ b/.github/fly-wsproxies/sao-paulo-coder.toml @@ -0,0 +1,28 @@ +app = "sao-paulo-coder" +primary_region = "gru" + +[experimental] + entrypoint = ["/opt/coder", "wsproxy", "server"] + auto_rollback = true + +[build] + image = "ghcr.io/coder/coder-preview:main" + +[env] + CODER_ACCESS_URL = "https://sao-paulo-coder.fly.dev" + CODER_HTTP_ADDRESS = "0.0.0.0:3000" + CODER_PRIMARY_ACCESS_URL = "https://dev.coder.com" + CODER_TELEMETRY_INSTALL_SOURCE = "fly.io" + PRIMARY_REGION = "gru" + +[http_service] + internal_port = 3000 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + +[[vm]] + cpu_kind = "shared" + cpus = 1 + memory_mb = 512 diff --git a/.github/fly-wsproxies/sydney-coder.toml b/.github/fly-wsproxies/sydney-coder.toml new file mode 100644 index 0000000000000..484522231ba40 --- /dev/null +++ b/.github/fly-wsproxies/sydney-coder.toml @@ -0,0 +1,28 @@ +app = "sydney-coder" +primary_region = "syd" + +[experimental] + entrypoint = ["/opt/coder", "wsproxy", "server"] + auto_rollback = true + +[build] + image = "ghcr.io/coder/coder-preview:main" + +[env] + CODER_ACCESS_URL = "https://sydney-coder.fly.dev" + CODER_HTTP_ADDRESS = "0.0.0.0:3000" + CODER_PRIMARY_ACCESS_URL = "https://dev.coder.com" + CODER_TELEMETRY_INSTALL_SOURCE = "fly.io" + PRIMARY_REGION = "syd" + +[http_service] + internal_port = 3000 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + +[[vm]] + cpu_kind = "shared" + cpus = 1 + memory_mb = 512 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 030f5a1ea06a3..4a0dee9a940ea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -633,7 +633,7 @@ jobs: # to main branch. We are only building this for amd64 platform. (>95% pulls # are for amd64) needs: changes - if: github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false' + # if: github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false' runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} env: DOCKER_CLI_EXPERIMENTAL: "enabled" @@ -688,6 +688,9 @@ jobs: docker tag "ghcr.io/coder/coder-preview:$tag" ghcr.io/coder/coder-preview:main docker push ghcr.io/coder/coder-preview:main + # Store the tag in an output variable so we can use it in other jobs + echo "tag=$tag" >> $GITHUB_OUTPUT + - name: Prune old images uses: vlaurin/action-ghcr-prune@v0.5.0 with: @@ -767,11 +770,11 @@ jobs: set -euxo pipefail kubectl --namespace coder rollout restart deployment/coder kubectl --namespace coder rollout status deployment/coder - + deploy-wsproxies: runs-on: ubuntu-latest needs: build - if: !github.event.pull_request.head.repo.fork + # if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork steps: - name: Checkout uses: actions/checkout@v4 @@ -783,11 +786,17 @@ jobs: - name: Deploy workspace proxies run: | - flyctl deploy --image ghcr.io/coder/coder-preview:main --app paris-coder -y - flyctl deploy --image ghcr.io/coder/coder-preview:main --app sydney-coder -y - flyctl deploy --image ghcr.io/coder/coder-preview:main --app sao-paulo-coder -y + flyctl deploy --image $IMAGE --app paris-coder --config ./.github/fly-wsproxies/paris-coder.toml --env CODER_PROXY_SESSION_TOKEN=$TOKEN_PARIS --yes + flyctl deploy --image $IMAGE --app sydney-coder --config ./.github/fly-wsproxies/sydney-coder.toml --env CODER_PROXY_SESSION_TOKEN=$TOKEN_SYDNEY --yes + flyctl deploy --image $IMAGE --app sao-paulo-coder --config ./.github/fly-wsproxies/sao-paulo-coder.toml --env CODER_PROXY_SESSION_TOKEN=$TOKEN_SAO_PAULO --yes env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} + IMAGE: "ghcr.io/coder/coder-preview:${{ needs.build.outputs.tag }}" + TOKEN_PARIS: ${{ secrets.FLY_PARIS_CODER_PROXY_SESSION_TOKEN }} + TOKEN_SYDNEY: ${{ secrets.FLY_SYDNEY_CODER_PROXY_SESSION_TOKEN }} + TOKEN_SAO_PAULO: ${{ secrets.FLY_SAO_PAULO_CODER_PROXY_SESSION_TOKEN }} + + # TODO: when we remove this, instead of removing it we need to change it so it # still upgrades workspace proxies which are not deployed on K8s From ded32a396b4527a07302af40dbed8e6a03e7a091 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Mon, 4 Dec 2023 00:19:25 +0300 Subject: [PATCH 09/12] fixuup! --- .github/workflows/ci.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a2009d3da27e1..5c0c89d83950a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -639,6 +639,8 @@ jobs: runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} env: DOCKER_CLI_EXPERIMENTAL: "enabled" + outputs: + IMAGE: ghcr.io/coder/coder-preview:${{ steps.build-docker.outputs.tag }} steps: - name: Checkout uses: actions/checkout@v4 @@ -677,6 +679,7 @@ jobs: build/coder_"$version"_linux_amd64.{tar.gz,deb} - name: Build and Push Linux amd64 Docker Image + id: build-docker run: | set -euxo pipefail version="$(./scripts/version.sh)" @@ -797,7 +800,7 @@ jobs: flyctl deploy --image $IMAGE --app sao-paulo-coder --config ./.github/fly-wsproxies/sao-paulo-coder.toml --env CODER_PROXY_SESSION_TOKEN=$TOKEN_SAO_PAULO --yes env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} - IMAGE: "ghcr.io/coder/coder-preview:${{ needs.build.outputs.tag }}" + IMAGE: ${{ needs.build.outputs.IMAGE }} TOKEN_PARIS: ${{ secrets.FLY_PARIS_CODER_PROXY_SESSION_TOKEN }} TOKEN_SYDNEY: ${{ secrets.FLY_SYDNEY_CODER_PROXY_SESSION_TOKEN }} TOKEN_SAO_PAULO: ${{ secrets.FLY_SAO_PAULO_CODER_PROXY_SESSION_TOKEN }} From ce8346af3413947b3d9f36fe09a61a4a8f9db87e Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Mon, 4 Dec 2023 00:35:55 +0300 Subject: [PATCH 10/12] ready --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5c0c89d83950a..2a604bfbacb48 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -635,7 +635,7 @@ jobs: # to main branch. We are only building this for amd64 platform. (>95% pulls # are for amd64) needs: changes - # if: github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false' + if: github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false' runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} env: DOCKER_CLI_EXPERIMENTAL: "enabled" @@ -783,7 +783,7 @@ jobs: deploy-wsproxies: runs-on: ubuntu-latest needs: build - # if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork + if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork steps: - name: Checkout uses: actions/checkout@v4 From d8d6d2ba821cd6d74ef4b1b241642098165d1e5a Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Mon, 4 Dec 2023 01:01:51 +0300 Subject: [PATCH 11/12] cleanup --- .github/fly-wsproxies/paris-coder.toml | 2 -- .github/fly-wsproxies/sao-paulo-coder.toml | 4 +--- .github/fly-wsproxies/sydney-coder.toml | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/fly-wsproxies/paris-coder.toml b/.github/fly-wsproxies/paris-coder.toml index 5178385a5ee15..53ff4ab6b16f1 100644 --- a/.github/fly-wsproxies/paris-coder.toml +++ b/.github/fly-wsproxies/paris-coder.toml @@ -12,8 +12,6 @@ primary_region = "cdg" CODER_ACCESS_URL = "https://paris-coder.fly.dev" CODER_HTTP_ADDRESS = "0.0.0.0:3000" CODER_PRIMARY_ACCESS_URL = "https://dev.coder.com" - CODER_TELEMETRY_INSTALL_SOURCE = "fly.io" - PRIMARY_REGION = "cdg" [http_service] internal_port = 3000 diff --git a/.github/fly-wsproxies/sao-paulo-coder.toml b/.github/fly-wsproxies/sao-paulo-coder.toml index 9f620f1bc9915..0a93c9790c8e7 100644 --- a/.github/fly-wsproxies/sao-paulo-coder.toml +++ b/.github/fly-wsproxies/sao-paulo-coder.toml @@ -12,9 +12,7 @@ primary_region = "gru" CODER_ACCESS_URL = "https://sao-paulo-coder.fly.dev" CODER_HTTP_ADDRESS = "0.0.0.0:3000" CODER_PRIMARY_ACCESS_URL = "https://dev.coder.com" - CODER_TELEMETRY_INSTALL_SOURCE = "fly.io" - PRIMARY_REGION = "gru" - + [http_service] internal_port = 3000 force_https = true diff --git a/.github/fly-wsproxies/sydney-coder.toml b/.github/fly-wsproxies/sydney-coder.toml index 484522231ba40..24436958b2ad5 100644 --- a/.github/fly-wsproxies/sydney-coder.toml +++ b/.github/fly-wsproxies/sydney-coder.toml @@ -12,8 +12,6 @@ primary_region = "syd" CODER_ACCESS_URL = "https://sydney-coder.fly.dev" CODER_HTTP_ADDRESS = "0.0.0.0:3000" CODER_PRIMARY_ACCESS_URL = "https://dev.coder.com" - CODER_TELEMETRY_INSTALL_SOURCE = "fly.io" - PRIMARY_REGION = "syd" [http_service] internal_port = 3000 From 52bf9e1c1eea5e894aa59c96e583e100b94d2bd5 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Mon, 4 Dec 2023 08:40:06 +0300 Subject: [PATCH 12/12] Update .github/workflows/ci.yaml Co-authored-by: Dean Sheather --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2a604bfbacb48..bfd37e27767ab 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -795,9 +795,9 @@ jobs: - name: Deploy workspace proxies run: | - flyctl deploy --image $IMAGE --app paris-coder --config ./.github/fly-wsproxies/paris-coder.toml --env CODER_PROXY_SESSION_TOKEN=$TOKEN_PARIS --yes - flyctl deploy --image $IMAGE --app sydney-coder --config ./.github/fly-wsproxies/sydney-coder.toml --env CODER_PROXY_SESSION_TOKEN=$TOKEN_SYDNEY --yes - flyctl deploy --image $IMAGE --app sao-paulo-coder --config ./.github/fly-wsproxies/sao-paulo-coder.toml --env CODER_PROXY_SESSION_TOKEN=$TOKEN_SAO_PAULO --yes + flyctl deploy --image "$IMAGE" --app paris-coder --config ./.github/fly-wsproxies/paris-coder.toml --env "CODER_PROXY_SESSION_TOKEN=$TOKEN_PARIS" --yes + flyctl deploy --image "$IMAGE" --app sydney-coder --config ./.github/fly-wsproxies/sydney-coder.toml --env "CODER_PROXY_SESSION_TOKEN=$TOKEN_SYDNEY" --yes + flyctl deploy --image "$IMAGE" --app sao-paulo-coder --config ./.github/fly-wsproxies/sao-paulo-coder.toml --env "CODER_PROXY_SESSION_TOKEN=$TOKEN_SAO_PAULO" --yes env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} IMAGE: ${{ needs.build.outputs.IMAGE }}