Skip to content

Commit

Permalink
🐳 trying depot build (#927)
Browse files Browse the repository at this point in the history
* 🐳 trying depot build

* 🐳 trying depot build

* 🐳 trying depot build

* 🐳 trying depot build

* 🐳 trying depot build

* 🐳 trying depot build

* 🐳 trying depot build

* 🐳 trying depot build

* 🐳 trying depot build
  • Loading branch information
thibaultleouay authored Jul 12, 2024
1 parent f84a315 commit 013eb09
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/publish-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish Checker
on:
push:
branches:
- main
paths:
- "apps/checker/**"
env:
REGISTRY: ghcr.io
IMAGE_NAME: checker

jobs:
build:
runs-on: ubuntu-latest
# Permissions to use OIDC token authentication
permissions:
contents: read
id-token: write
# Allows pushing to the GitHub Container Registry
packages: write
steps:
- uses: actions/checkout@v3
- uses: depot/setup-action@v1
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: depot/build-push-action@v1
with:
project: 9cknw183m8
context: apps/checker
tags: ghcr.io/openstatushq/checker:latest
push: true

2 changes: 2 additions & 0 deletions apps/checker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ fly deploy
```bash
fly scale count 35 --region ams,arn,atl,bog,bom,bos,cdg,den,dfw,ewr,eze,fra,gdl,gig,gru,hkg,iad,jnb,lax,lhr,mad,mia,nrt,ord,otp,phx,qro,scl,sjc,sea,sin,syd,waw,yul,yyz
```

## Build
28 changes: 17 additions & 11 deletions apps/checker/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ func main() {
}()

// environment variables.
flyRegion := env("FLY_REGION", "local")
flyRegion := env("FLY_REGION", env("REGION", "local"))
cronSecret := env("CRON_SECRET", "")
tinyBirdToken := env("TINYBIRD_TOKEN", "")
logLevel := env("LOG_LEVEL", "warn")
cloudProvider := env("CLOUD_PROVIDER", "fly")

logger.Configure(logLevel)

Expand All @@ -79,12 +80,14 @@ func main() {
return
}

// if the request has been routed to a wrong region, we forward it to the correct one.
region := c.GetHeader("fly-prefer-region")
if region != "" && region != flyRegion {
c.Header("fly-replay", fmt.Sprintf("region=%s", region))
c.String(http.StatusAccepted, "Forwarding request to %s", region)
return
if cloudProvider == "fly" {
// if the request has been routed to a wrong region, we forward it to the correct one.
region := c.GetHeader("fly-prefer-region")
if region != "" && region != flyRegion {
c.Header("fly-replay", fmt.Sprintf("region=%s", region))
c.String(http.StatusAccepted, "Forwarding request to %s", region)
return
}
}

var req request.CheckerRequest
Expand Down Expand Up @@ -275,10 +278,13 @@ func main() {
return
}

if region != flyRegion {
c.Header("fly-replay", fmt.Sprintf("region=%s", region))
c.String(http.StatusAccepted, "Forwarding request to %s", region)
return
if cloudProvider == "fly" {

if region != flyRegion {
c.Header("fly-replay", fmt.Sprintf("region=%s", region))
c.String(http.StatusAccepted, "Forwarding request to %s", region)
return
}
}
// We need a new client for each request to avoid connection reuse.
requestClient := &http.Client{
Expand Down

0 comments on commit 013eb09

Please sign in to comment.