Skip to content

Commit

Permalink
Add mage targets for managing our remote Dagger Engine
Browse files Browse the repository at this point in the history
We start this in the pipeline, when needed, and stop it when the job
finishes running.

Signed-off-by: Gerhard Lazu <[email protected]>
  • Loading branch information
gerhard committed Jul 2, 2023
1 parent 38f31f0 commit 499d19b
Show file tree
Hide file tree
Showing 8 changed files with 237 additions and 77 deletions.
66 changes: 41 additions & 25 deletions .github/workflows/ship_it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
- name: "Checkout code..."
uses: actions/checkout@v3

# ⚠️ FLY_WIREGUARD is configured via `fly wireguard create ...` - see 2022.fly/docker/README.md
- name: "Set up WireGuard for Fly.io Docker Engine..."
# ⚠️ FLY_WIREGUARD is configured via `fly wireguard create ...` - see fly.io/dagger-engine-2023-05-20/README.md
- name: "Set up WireGuard for Dagger Engine on Fly.io..."
env:
FLY_WIREGUARD: ${{ secrets.FLY_WIREGUARD }}
if: "${{ env.FLY_WIREGUARD != '' }}"
Expand All @@ -26,41 +26,57 @@ jobs:
printf "${{ secrets.FLY_WIREGUARD }}" | sudo tee /etc/wireguard/fly.conf
sudo wg-quick up fly
# ⚠️ IPv6 is configured via `fly ips private` - see 2022.fly/docker/README.md
- name: "Check Fly.io Docker Engine"
env:
DOCKER_ENGINE_HOST: ${{ secrets.DOCKER_ENGINE_HOST }}
if: "${{ env.DOCKER_ENGINE_HOST != '' }}"
run: |
ping6 -c 5 "$DOCKER_ENGINE_HOST"
nc -vz6 "$DOCKER_ENGINE_HOST" 2375
- uses: actions/setup-go@v4
with:
go-version: "1.20"
cache-dependency-path: magefiles/go.sum

- name: "Start remote Dagger Engine..."
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
FLY_PRIMARY_DAGGER_ENGINE_MACHINE_ID: "${{ vars.FLY_PRIMARY_DAGGER_ENGINE_MACHINE_ID }}"
FLY_SECONDARY_DAGGER_ENGINE_MACHINE_ID: "${{ vars.FLY_SECONDARY_DAGGER_ENGINE_MACHINE_ID }}"
DAGGER_ENGINE_HOST: ${{ vars.DAGGER_ENGINE_HOST }}
if: "${{ env.DAGGER_ENGINE_HOST != '' }}"
run: |
cd magefiles
go run main.go -w ../ fly:daggerStart
ping6 -c 5 "$DAGGER_ENGINE_HOST"
nc -vz6 "$DAGGER_ENGINE_HOST" 8080
- name: "Build, test, publish & deploy..."
env:
DOCKER_HOST: "${{ secrets.DOCKER_ENGINE_HOST_FQDN }}"
IMAGE_OWNER: "${{ secrets.IMAGE_OWNER }}"
IMAGE_OWNER: "${{ vars.IMAGE_OWNER }}"
GHCR_USERNAME: "${{ github.actor }}"
GHCR_PASSWORD: "${{ secrets.GHCR_PASSWORD }}"
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
_EXPERIMENTAL_DAGGER_RUNNER_HOST: "${{ vars._EXPERIMENTAL_DAGGER_RUNNER_HOST }}"
run: |
cd magefiles
go run main.go -w ../ ci cd
notify:
if: ${{ github.repository == 'thechangelog/changelog.com' && github.ref_name == 'master' }}
needs: cicd
runs-on: ubuntu-latest
steps:
- name: "Notify Slack about deploy..."
uses: rtCamp/action-slack-notify@v2
- name: "Stop remote Dagger Engine..."
env:
MSG_MINIMAL: "commit,actions url"
SLACK_CHANNEL: dev
SLACK_USERNAME: "GitHub Actions"
SLACK_FOOTER: "Just got shipped to https://changelog.com"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
FLY_PRIMARY_DAGGER_ENGINE_MACHINE_ID: "${{ vars.FLY_PRIMARY_DAGGER_ENGINE_MACHINE_ID }}"
FLY_SECONDARY_DAGGER_ENGINE_MACHINE_ID: "${{ vars.FLY_SECONDARY_DAGGER_ENGINE_MACHINE_ID }}"
if: "${{ env.FLY_PRIMARY_DAGGER_ENGINE_MACHINE_ID != '' }}"
run: |
cd magefiles
go run main.go -w ../ fly:daggerStop
# notify:
# if: ${{ github.repository == 'thechangelog/changelog.com' && github.ref_name == 'master' }}
# needs: cicd
# runs-on: ubuntu-latest
# steps:
# - name: "Notify Slack about deploy..."
# uses: rtCamp/action-slack-notify@v2
# env:
# MSG_MINIMAL: "commit,actions url"
# SLACK_CHANNEL: dev
# SLACK_USERNAME: "GitHub Actions"
# SLACK_FOOTER: "Just got shipped to https://changelog.com"
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
direnv 2.32.2
direnv 2.32.3
elixir 1.14.4
erlang 25.3.2
golang 1.20.4
nodejs 18.16.0
yarn 1.22.19
postgres 14.1
flyctl 0.1.8
flyctl 0.1.45
mage 1.15.0
26 changes: 14 additions & 12 deletions fly.io/dagger-engine-2023-05-20/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

## Deploy

Follow these steps to deploy a Dagger Engine on Fly.io:
Follow these steps to deploy two Dagger Engines on Fly.io, the primary in `ewr
Secaucus, NJ (US)` & the secondary in `ord Chicago, Illinois (US)`:

1. Create the `fly.toml`
2. `flyctl apps create dagger-engine-2023-05-20 --org changelog`
3. `flyctl volumes create dagger_engine_2023_05_20 --size 50 --region iad`
4. `flyctl deploy --vm-size performance-4x`
3. `flyctl volumes create dagger_engine_2023_05_20 --size 100 --region ewr` 👈 primary region
4. `flyctl deploy --vm-size performance-4x --region ewr`
5. `flyctl machine clone --region ord <PRIMARY_MACHINE_ID>` 👈 secondary region

## Connect

Expand All @@ -31,19 +33,19 @@ Delete the volume: `flyctl volume list` && `flyctl volume destroy <VOLUME_ID>`.
**slower**. After the first run, the build cache will get populated &
everything will continue being just as fast as when we had data on this volume.

## Benchmark
## Benchmark on `2023.07.02`

TL;DR `performance-4x` continues being the sweet spot.
TL;DR `performance-4x` continues being the sweet spot (it's the same size that
we used for Docker).

We ran
`_EXPERIMENTAL_DAGGER_RUNNER_HOST=tcp://dagger-engine-2023-05-20.internal:8080
dagger run mage ci` multiple times - COLD (no cache) & HOT (cache) - to see the
performance gain from using more CPUs / memory.


| VM SIZE | COLD | HOT |
| --- | --- | --- |
| performance-16x | `5m 1s` | `1m 44s` |
| performance-8x | `4m 58s` | `1m 35s` |
| performance-4x | `5m 30s` | `1m 25s` |
| performance-2x | `8m 2s` | `1m 42s` |
| VM SIZE | COLD | HOT |
| --- | --- | --- |
| performance-16x | `4m 54s` - `1.63x` | `1m 42s` - `1.00x` |
| performance-8x | `4m 52s` - `1.65x` | `1m 35s` - `1.07x` |
| performance-4x 👉 | `4m 59s` - `1.61x` | `1m 35s` - `1.07x` |
| performance-2x | `8m 02s` - `1.00x` | `1m 42s` - `1.00x` |
8 changes: 4 additions & 4 deletions fly.io/dagger-engine-2023-05-20/fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ kill_signal = "SIGINT"
kill_timeout = 30

[build]
image = "registry.dagger.io/engine:v0.5.3"
image = "registry.dagger.io/engine:v0.6.2"

[env]
_EXPERIMENTAL_DAGGER_SERVICES_DNS = "true"
Expand All @@ -21,8 +21,8 @@ kill_timeout = 30

[checks]
[checks.grpc]
grace_period = "2s"
interval = "3s"
grace_period = "3s"
interval = "2s"
port = 8080
timeout = "2s"
timeout = "1s"
type = "tcp"
15 changes: 8 additions & 7 deletions magefiles/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ module github.com/thechangelog/changelog.com/magefiles
go 1.20

require (
dagger.io/dagger v0.6.3
github.com/magefile/mage v1.14.0
dagger.io/dagger v0.7.2
github.com/magefile/mage v1.15.0
)

require (
github.com/99designs/gqlgen v0.17.34 // indirect
github.com/Khan/genqlient v0.6.0 // indirect
github.com/adrg/xdg v0.4.0 // indirect
github.com/iancoleman/strcase v0.2.0 // indirect
github.com/vektah/gqlparser/v2 v2.5.1 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/tools v0.9.1 // indirect
github.com/vektah/gqlparser/v2 v2.5.6 // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/tools v0.10.0 // indirect
)
41 changes: 22 additions & 19 deletions magefiles/go.sum
Original file line number Diff line number Diff line change
@@ -1,46 +1,49 @@
dagger.io/dagger v0.6.3 h1:9SMqCjC+9GEVFUjOqTbDWJudwkJGKOWpnEzsGHBBDkA=
dagger.io/dagger v0.6.3/go.mod h1:/sSGPh+1LInVuHzTkkr1pZ5N0BAEDoqJ94eM2Xoh/iE=
dagger.io/dagger v0.7.2 h1:gs4z2nyFPy7U35KmCgr0sZapz7xI8n8cso71D0YHb9w=
dagger.io/dagger v0.7.2/go.mod h1:TgNJZFyAh/fTRldRw1vrBKc4c5XfBtZ6i+kfg2C3BHY=
github.com/99designs/gqlgen v0.17.34 h1:5cS5/OKFguQt+Ws56uj9FlG2xm1IlcJWNF2jrMIKYFQ=
github.com/99designs/gqlgen v0.17.34/go.mod h1:Axcd3jIFHBVcqzixujJQr1wGqE+lGTpz6u4iZBZg1G8=
github.com/Khan/genqlient v0.6.0 h1:Bwb1170ekuNIVIwTJEqvO8y7RxBxXu639VJOkKSrwAk=
github.com/Khan/genqlient v0.6.0/go.mod h1:rvChwWVTqXhiapdhLDV4bp9tz/Xvtewwkon4DpWWCRM=
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo=
github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/vektah/gqlparser/v2 v2.5.1 h1:ZGu+bquAY23jsxDRcYpWjttRZrUz07LbiY77gUOHcr4=
github.com/vektah/gqlparser/v2 v2.5.1/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs=
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
github.com/vektah/gqlparser/v2 v2.5.6 h1:Ou14T0N1s191eRMZ1gARVqohcbe1e8FrcONScsq8cRU=
github.com/vektah/gqlparser/v2 v2.5.6/go.mod h1:z8xXUff237NntSuH8mLFijZ+1tjV1swDbpDqjJmk6ME=
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=
golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg=
golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Loading

0 comments on commit 499d19b

Please sign in to comment.