containers/apps/lix-builder
2024-11-10 10:52:22 +00:00
..
ci chore: adding backlog of additions 2024-11-03 21:28:24 +01:00
packages chore(lix-builder): migrate dockerfile to flake and add initial takes on flux_local as helper functions 2024-11-10 10:28:01 +01:00
flake.lock chore(lix-builder): migrate dockerfile to flake and add initial takes on flux_local as helper functions 2024-11-10 10:28:01 +01:00
flake.nix chore(lix-builder): migrate dockerfile to flake and add initial takes on flux_local as helper functions 2024-11-10 10:28:01 +01:00
manifest.yaml chore: adding backlog of additions 2024-11-03 21:28:24 +01:00
metadata.yaml chore: adding backlog of additions 2024-11-03 21:28:24 +01:00
README.md Update apps/lix-builder/README.md 2024-11-10 10:52:22 +00:00

Flakes Action

This container is a little special since it provides a Nix flake designed to generate a docker image to use with Forgejo runners. It packages essential tools and helper programs to streamline the code.252.no CI/CD workflows.

We try to reproduce much-used GitHub actions into one package to avoid calling an excessive amount of images in Forgejo workflows.

Supported use cases

  • Flux CI/CD testing
  • Forgejo comments: post comments to issues
  • Run commands ad-hoc with nix run

Docker Image Info

The latest container resulting from the nix build, is located in the registry at code.252.no/tommy/flakes-action:latest and includes:

  • Nix Environment: Pre-configured with Nix and essential configurations.
  • Helper Programs: Bundles flux-local, flux-diff, and forgejo-comment.
  • Essential Build Tools: Includes utilities like git, docker, bash, curl, jq, and more.

Nix Flake Info

  • Apps: Accessible via nix run or nix shell commands.
  • Packages: Builds the flakes-action Docker image named flakes-action with necessary tools.

Helper Programs Provided

The flake provides the following applications:

Application Description External Ref
git-sv Semantic versioning tool for git based on conventional commits. tommy/git-sv
flux-local Tool for performing local Flux operations and diffs. allenporter/flux-local
flux-diff Utility to diff Flux resources locally. buroa/k8s-gitops
forgejo-comment Script to post comments on Forgejo merge requests. -

Other standard packages are provided from nixpkgs. For an up-to-date list have a look at flakes-action in flake.nix.

Usage

Building

We provide an example taskfile in task docker:build-flakesaction which is used for manual builds at code.252.no. The task uses nerdctl, but you may replace this with docker or podman.

nix build .#packages.x86_64-linux.flakes-action # build image
nerdctl load < result # loads nix build result (tar archive)
nerdctl push code.252.no/tommy/flakes-action:latest # push to registry

In Runner

We provide examples for use in Kubernetes, but the image may be used with the act runner locally as well.

To use the Docker image in your Forgejo runner add it to your Helm values (this uses the bjw-s app-template):

[...]
  values:
    controllers:
      forgejo-runner-elkworks:
        replicas: 2
        initContainers:
          runner-register:
            image:
              repository: code.forgejo.org/forgejo/runner
              tag: 4.0.1
            command:
            - "forgejo-runner"
            - "register"
            - "--no-interactive"
            - "--token"
            - $(RUNNER_TOKEN)
            - "--name"
            - $(RUNNER_NAME)
            - "--instance"
            - $(FORGEJO_INSTANCE_URL)
            - "--labels"
            - "flakes-action:docker://code.252.no/tommy/flakes-action:latest,[...]"
            env:
            - name: RUNNER_TOKEN
              valueFrom:
                secretKeyRef:
                  name: forgejo-runner-elkworks-secret
                  key: RUNNER_TOKEN
            - name: RUNNER_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: FORGEJO_INSTANCE_URL
              value: https://code.252.no
[...]