CI/CD Pipeline
Netshoot uses GitHub Actions for its Continuous Integration and Continuous Deployment (CI/CD) pipeline. The workflows are defined in the .github/workflows/ directory and handle testing pull requests and publishing release images.
Testing Pull Requests (test-pr-buildx.yml)
This workflow ensures that proposed changes don't break the build process.
- Trigger: Runs on every pull request targeting the
masterbranch. -
Actions:
- Checkout Code: Checks out the source code from the pull request.
- Set up QEMU: Configures QEMU to enable building for different CPU architectures (specifically
arm64on anamd64runner). - Set up Docker Buildx: Initializes the Docker Buildx builder instance.
-
Run Buildx: Executes a multi-platform build for
linux/amd64andlinux/arm64.docker buildx build \ --platform linux/amd64,linux/arm64 \ --output "type=image,push=false" \ --file ./Dockerfile . -
Result: The key part is
--output "type=image,push=false". The workflow only builds the image to confirm that theDockerfileand related scripts are working correctly for all target platforms. It does not push the resulting image to any registry.
Creating a Release (release-buildx.yml)
This workflow automates the process of building and publishing the official Netshoot images when a new version is tagged.
- Trigger: Runs whenever a push event includes a tag matching the pattern
v*(e.g.,v0.14,v1.0). -
Actions:
- Checkout & Setup: Similar to the PR workflow, it checks out the code and sets up QEMU and Docker Buildx.
- Login to Registries: It logs into both Docker Hub and the GitHub Container Registry (GHCR) using secrets stored in the repository.
-
Run Buildx and Push: It runs the multi-platform build with a different output configuration:
docker buildx build \ --platform linux/amd64,linux/arm64 \ --output "type=image,push=true" \ --file ./Dockerfile \ --tag nicolaka/netshoot:$RELEASE_VERSION \ --tag nicolaka/netshoot:latest \ --tag ghcr.io/nicolaka/netshoot:$RELEASE_VERSION \ --tag ghcr.io/nicolaka/netshoot:latest \ . -
Result: The
--output "type=image,push=true"flag instructs Buildx to build the images and push them to the specified registries with multiple tags (the specific version tag andlatest).