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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/fly-wsproxies/paris-coder.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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"

[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
26 changes: 26 additions & 0 deletions .github/fly-wsproxies/sao-paulo-coder.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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"

[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
26 changes: 26 additions & 0 deletions .github/fly-wsproxies/sydney-coder.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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"

[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
31 changes: 31 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)"
Expand All @@ -694,6 +697,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:
Expand Down Expand Up @@ -774,6 +780,31 @@ jobs:
kubectl --namespace coder rollout restart deployment/coder
kubectl --namespace coder rollout status deployment/coder

deploy-wsproxies:
runs-on: ubuntu-latest
needs: build
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 "$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 }}
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 }}
Comment on lines +804 to +806
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fly.io doesn't have a way of adding secrets in their dashboard?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do have but I prefer we store all secrets in GitHub Actions. I can move if you disagree.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use --env on the flyctl command does it store the secrets in plain text visible on the fly.io dashboard? If so then we should probably move them to secrets on fly.io instead of GH

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fly.io has no environment section on the dashboard, so they do not appear anywhere.


deploy-legacy-proxies:
name: "deploy-legacy-proxies"
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
Expand Down