Skip to content

Commit

Permalink
chore: move Docker images to Docker Hub because GHCR is private and t…
Browse files Browse the repository at this point in the history
…hat sucks (#1868)

Plus some other minor fixes.
  • Loading branch information
alecthomas authored Jun 25, 2024
1 parent e661e29 commit 38de28c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 33 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
uses: cashapp/activate-hermit@v1
- name: Build
run: |
docker build -t ghcr.io/tbd54566975/ftl-runner:"$GITHUB_SHA" -t ghcr.io/tbd54566975/ftl-runner:latest -f Dockerfile.runner .
docker build -t ftl0/ftl-runner:"$GITHUB_SHA" -t ftl0/ftl-runner:latest -f Dockerfile.runner .
mkdir -p artifacts/ftl-runner
docker save -o artifacts/ftl-runner/ftl-runner.tar ghcr.io/tbd54566975/ftl-runner:latest
docker save -o artifacts/ftl-runner/ftl-runner.tar ftl0/ftl-runner:latest
- name: Temporarily save Docker image
uses: actions/upload-artifact@v4
with:
Expand All @@ -34,9 +34,9 @@ jobs:
uses: cashapp/activate-hermit@v1
- name: Build
run: |
docker build -t ghcr.io/tbd54566975/ftl-controller:"$GITHUB_SHA" -t ghcr.io/tbd54566975/ftl-controller:latest -f Dockerfile.controller .
docker build -t ftl0/ftl-controller:"$GITHUB_SHA" -t ftl0/ftl-controller:latest -f Dockerfile.controller .
mkdir -p artifacts/ftl-controller
docker save -o artifacts/ftl-controller/ftl-controller.tar ghcr.io/tbd54566975/ftl-controller:latest
docker save -o artifacts/ftl-controller/ftl-controller.tar ftl0/ftl-controller:latest
- name: Temporarily save Docker image
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -74,18 +74,17 @@ jobs:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
username: ftl0
password: ${{ secrets.FTL_DOCKER_PUSH_TOKEN }}
- name: Push Docker Images
run: |
version="$(git describe --tags --abbrev=0)"
docker tag ghcr.io/tbd54566975/ftl-runner:latest ghcr.io/tbd54566975/ftl-runner:"$GITHUB_SHA"
docker tag ghcr.io/tbd54566975/ftl-runner:latest ghcr.io/tbd54566975/ftl-runner:"$version"
docker push -a ghcr.io/tbd54566975/ftl-runner
docker tag ghcr.io/tbd54566975/ftl-controller:latest ghcr.io/tbd54566975/ftl-controller:"$GITHUB_SHA"
docker tag ghcr.io/tbd54566975/ftl-controller:latest ghcr.io/tbd54566975/ftl-controller:"$version"
docker push -a ghcr.io/tbd54566975/ftl-controller
docker tag ftl0/ftl-runner:latest ftl0/ftl-runner:"$GITHUB_SHA"
docker tag ftl0/ftl-runner:latest ftl0/ftl-runner:"$version"
docker push -a ftl0/ftl-runner
docker tag ftl0/ftl-controller:latest ftl0/ftl-controller:"$GITHUB_SHA"
docker tag ftl0/ftl-controller:latest ftl0/ftl-controller:"$version"
docker push -a ftl0/ftl-controller
create-release:
name: Release Go Binaries
runs-on: ubuntu-latest
Expand Down
22 changes: 14 additions & 8 deletions buildengine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,18 @@ func (e *Engine) Build(ctx context.Context) error {
return e.buildWithCallback(ctx, nil)
}

// Each iterates over all local modules.
func (e *Engine) Each(fn func(Module) error) (err error) {
e.moduleMetas.Range(func(key string, value moduleMeta) bool {
if ferr := fn(value.module); ferr != nil {
err = fmt.Errorf("%s: %w", key, ferr)
return false
}
return true
})
return
}

// Deploy attempts to build and deploy all local modules.
func (e *Engine) Deploy(ctx context.Context, replicas int32, waitForDeployOnline bool) error {
return e.buildAndDeploy(ctx, replicas, waitForDeployOnline)
Expand Down Expand Up @@ -429,11 +441,10 @@ func (e *Engine) buildAndDeploy(ctx context.Context, replicas int32, waitForDepl
}

buildGroup := errgroup.Group{}
deployGroup := errgroup.Group{}

buildGroup.Go(func() error {
return e.buildWithCallback(ctx, func(buildCtx context.Context, module Module) error {
deployGroup.Go(func() error {
buildGroup.Go(func() error {
e.modulesToBuild.Store(module.Config.Module, false)
return Deploy(buildCtx, module, replicas, waitForDeployOnline, e.client)
})
Expand All @@ -443,7 +454,6 @@ func (e *Engine) buildAndDeploy(ctx context.Context, replicas int32, waitForDepl

// Wait for all build and deploy attempts to complete
buildErr := buildGroup.Wait()
deployErr := deployGroup.Wait()

pendingInitialBuilds := []string{}
e.modulesToBuild.Range(func(name string, value bool) bool {
Expand All @@ -458,11 +468,7 @@ func (e *Engine) buildAndDeploy(ctx context.Context, replicas int32, waitForDepl
logger.Infof("Modules waiting to build: %s", strings.Join(pendingInitialBuilds, ", "))
}

if buildErr != nil {
return buildErr
}

return deployErr
return buildErr
}

type buildCallback func(ctx context.Context, module Module) error
Expand Down
12 changes: 7 additions & 5 deletions cmd/ftl/cmd_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ package main
import (
"context"
"errors"
"fmt"

"github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect"
"github.com/TBD54566975/ftl/buildengine"
"github.com/TBD54566975/ftl/common/projectconfig"
"github.com/TBD54566975/ftl/internal/rpc"
)

type buildCmd struct {
Parallelism int `short:"j" help:"Number of modules to build in parallel." default:"${numcpu}"`
Dirs []string `arg:"" help:"Base directories containing modules." type:"existingdir" optional:""`
Dirs []string `arg:"" help:"Base directories containing modules (defaults to modules in project config)." type:"existingdir" optional:""`
}

func (b *buildCmd) Run(ctx context.Context, projConfig projectconfig.Config) error {
client := rpc.ClientFromContext[ftlv1connect.ControllerServiceClient](ctx)
func (b *buildCmd) Run(ctx context.Context, client ftlv1connect.ControllerServiceClient, projConfig projectconfig.Config) error {
if len(b.Dirs) == 0 {
b.Dirs = projConfig.AbsModuleDirs()
}
Expand All @@ -27,5 +26,8 @@ func (b *buildCmd) Run(ctx context.Context, projConfig projectconfig.Config) err
if err != nil {
return err
}
return engine.Build(ctx)
if err := engine.Build(ctx); err != nil {
return fmt.Errorf("build failed: %w", err)
}
return nil
}
2 changes: 1 addition & 1 deletion deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ make docker-controller
Tag the image for the local registry:

```
docker tag ghcr.io/tbd54566975/ftl-controller:latest localhost:5000/ftl-controller
docker tag ftl0/ftl-controller:latest localhost:5000/ftl-controller
```

Push the image to the local registry:
Expand Down
2 changes: 1 addition & 1 deletion deployment/ftl-controller/ftl-controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: app
image: ghcr.io/tbd54566975/ftl-controller
image: ftl0/ftl-controller
env:
- name: MY_POD_IP
valueFrom:
Expand Down
2 changes: 1 addition & 1 deletion deployment/ftl-runner/ftl-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: app
image: ghcr.io/tbd54566975/ftl-runner
image: ftl0/ftl-runner
env:
- name: MY_POD_IP
valueFrom:
Expand Down
8 changes: 4 additions & 4 deletions deployment/kustomization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ resources:
- ftl-controller
- ftl-runner
images:
- name: ghcr.io/tbd54566975/ftl-controller
newName: ghcr.io/tbd54566975/ftl-controller
- name: ftl0/ftl-controller
newName: ftl0/ftl-controller
newTag: latest
- name: ghcr.io/tbd54566975/ftl-runner
newName: ghcr.io/tbd54566975/ftl-runner
- name: ftl0/ftl-runner
newName: ftl0/ftl-runner
newTag: latest

0 comments on commit 38de28c

Please sign in to comment.