From 3747c6e5c496f34b36f7986d3b9358d2cd9fed46 Mon Sep 17 00:00:00 2001 From: Gerhard Lazu Date: Fri, 11 Feb 2022 15:31:15 +0000 Subject: [PATCH] First pass at the Go on Docker Swarm doc page There are a few more things to do before we can finish this, see the comments in the doc. The most important item is to switch the Dagger config to Europa. That is actually one of the next steps. Sharing this early so that we start collaborating. Pushing to a branch in the dagger org so that we can work on it together (personal repositories make it more difficult). Signed-off-by: Gerhard Lazu --- docs/use-cases/1211-go-docker-swarm.md | 95 +++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-) diff --git a/docs/use-cases/1211-go-docker-swarm.md b/docs/use-cases/1211-go-docker-swarm.md index 6bea76eb..98008b3a 100644 --- a/docs/use-cases/1211-go-docker-swarm.md +++ b/docs/use-cases/1211-go-docker-swarm.md @@ -5,4 +5,97 @@ displayed_sidebar: europaSidebar # Go on Docker Swarm -[particubes.com](https://particubes.com) +> TODO: particubes.com screenshot + +[Particubes](https://particubes.com) is a platform dedicated to voxel games, which are games made out of little cubes (like Minecraft). +The team consists of 10 developers that like to keep things simple. + +Particubes chose Dagger because it was the easiest way to integrate with their Docker Swarm production setup. +Every commit to the main branch gets deployed straight to [particubes.com](https://particubes.com) with Dagger running in GitHub Actions. +The Dagger Universe made it very easy for to build this pipeline. +`docker.#Build`, `docker.#Push` and `docker.#Command` was all that it took. + +:::danger +TODO: this config is pre-Europa, the next step is to convert it to Europa. +::: + +This is the entire Particubes Dagger plan: + +```cue +package particubes + +import ( + "alpha.dagger.io/dagger" + "alpha.dagger.io/docker" +) + +repo: dagger.#Input & {dagger.#Artifact} + +swarmSSH: { + user: dagger.#Input & {*"ubuntu" | string} + host: dagger.#Input & {string} + key: dagger.#Input & {dagger.#Secret} +} + +docs: { + containerImageName: dagger.#Input & {string} + containerImageTag: dagger.#Input & {*"latest" | string} + + // TODO: write the GIT_SHA into a static /git_sha.txt + buildContainerImage: docker.#Build & { + source: repo + } + + // TODO: + // - [ ] bootContainer + // - [ ] checkHttpResponse + // - [ ] stopContainer + + publishContainerImage: docker.#Push & { + "target": "\(containerImageName):\(containerImageTag)" + source: buildContainerImage + } + + deployContainerImage: docker.#Command & { + ssh: swarmSSH + command: "docker service update --image registry.particubes.com/lua-docs:$IMAGE_REF lua-docs" + env: { + "IMAGE_REF": publishContainerImage.ref + } + } + + // TODO: // check that the expected GIT_SHA is running in production + // checkHttpResponse /git_sha.txt +} +``` + +You can find [the original pipeline](https://github.com/voxowl/particubes/blob/b698777465c02462296de37087dd3c341c29df92/lua-docs/docs.cue) in the Particubes GitHub repository. + +Anyone on the Particubes team can run this pipeline locally using `dagger up`. +It also runs in GitHub Actions on every commit using the following config: + +```yaml +name: Dagger/docs.particubes.com + +on: + push: + branches: [ master ] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + lfs: true + - name: Dagger + uses: dagger/dagger-action@v1 + with: + age-key: ${{ secrets.DAGGER_AGE_KEY }} + args: up -e docs +``` + +### What comes next for particubes.com? + +We don't know but we would like find out 😀