Skip to content

chore: deploy workspace proxies on fly.io #10983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Dec 4, 2023
Prev Previous commit
Next Next commit
Merge branch 'main' into fly-wsproxy
  • Loading branch information
matifali authored Dec 1, 2023
commit af7790f600527e6de24bb68339280ff7662daedb
134 changes: 20 additions & 114 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -389,120 +389,6 @@ jobs:
with:
api-key: ${{ secrets.DATADOG_API_KEY }}

deploy:
name: "deploy"
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
timeout-minutes: 30
needs: changes
if: |
github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
&& needs.changes.outputs.docs-only == 'false'
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com

- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1

- name: Setup Node
uses: ./.github/actions/setup-node

- name: Setup Go
uses: ./.github/actions/setup-go

- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Install nfpm
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0

- name: Install zstd
run: sudo apt-get install -y zstd

- name: Build Release
run: |
set -euo pipefail
go mod download

version="$(./scripts/version.sh)"
make gen/mark-fresh
make -j \
build/coder_"$version"_windows_amd64.zip \
build/coder_"$version"_linux_amd64.{tar.gz,deb}

- name: Install Release
run: |
set -euo pipefail

regions=(
# gcp-region-id instance-name systemd-service-name
"us-central1-a coder coder"
"australia-southeast1-b coder-sydney coder-workspace-proxy"
"europe-west3-c coder-europe coder-workspace-proxy"
"southamerica-east1-b coder-brazil coder-workspace-proxy"
)

deb_pkg="./build/coder_$(./scripts/version.sh)_linux_amd64.deb"
if [ ! -f "$deb_pkg" ]; then
echo "deb package not found: $deb_pkg"
ls -l ./build
exit 1
fi

gcloud config set project coder-dogfood
for region in "${regions[@]}"; do
echo "::group::$region"
set -- $region

set -x
gcloud config set compute/zone "$1"
gcloud compute scp "$deb_pkg" "${2}:/tmp/coder.deb"
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"
set +x

echo "::endgroup::"
done

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: coder
path: |
./build/*.zip
./build/*.tar.gz
./build/*.deb
retention-days: 7

deploy-wsproxies:
runs-on: ubuntu-latest
needs: build-main-image
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
Expand Down Expand Up @@ -881,6 +767,26 @@ 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-main-image
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 }}

# 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
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.