A container image for GitLab CI/CD operations with various tools pre-installed. This image is designed to be used as a base image for GitLab CI/CD pipelines.
- Based on Debian bookworm-slim
- Includes Python, uv package manager, and Tectonic for LaTeX builds
- YAML linting with yamllint
- Pre-commit support with initialized Git repository in workspace
- Various utilities for build and automation tasks
- Version label automatically injected during CI/CD build process
This repository includes a GitHub Actions workflow that builds and publishes the Docker image using a custom Docker action. The workflow:
- Runs on pushes to the main branch that modify the Dockerfile
- Runs on tag pushes that start with 'v' (e.g., v1.0.0)
- Can be manually triggered using workflow_dispatch
- Uses a reusable Docker action to build, test, and publish images
- The release job only runs when a tag is pushed, automatically publishing to GitHub Container Registry (GHCR)
To use the workflow:
- The workflow runs automatically when changes are made to the Dockerfile
- You can manually trigger it from the Actions tab in GitHub
- To publish the image to the registry, create and push a tag that starts with 'v' (e.g.,
git tag v1.0.0 && git push origin v1.0.0) - When a tag is pushed, the image will be tagged with the specific version (e.g., v1.0.0) and the version label will be automatically set to the tag value
This repository also includes a manual release workflow that creates a Git tag, builds a Docker image, and creates a GitHub release. The workflow:
- Can be manually triggered using workflow_dispatch with a tag input
- Creates a Git tag based on the provided input
- Builds and publishes the Docker image with the specified tag to GitHub Container Registry (GHCR)
- Automatically injects the tag as the version label in the Docker image
- Creates a GitHub release with automatically generated release notes
- Includes Docker artifacts in the release
- Adds Docker image information to the release notes, including the image URL and pull command
- Requires
packages: writepermission to push images to GitHub Container Registry
To use the release workflow:
- Go to the Actions tab in GitHub and select the "Release Workflow"
- Click "Run workflow" and enter a release tag (e.g., v1.2.3)
- The workflow will create the Git tag, build and publish the Docker image, and create a GitHub release
- The Docker image will be available at
ghcr.io/{repository}/ci-image:{tag}and can be pulled withdocker pull ghcr.io/{repository}/ci-image:{tag} - The GitHub release will include a section with the Docker image URL and pull command
To build the Docker image locally with a custom version:
# Build with a specific version
docker build -t ci-image:custom --build-arg VERSION="1.2.3" ./docker
# Verify the version label
docker inspect ci-image:custom --format='{{.Config.Labels.version}}'The VERSION build argument will be injected as the version label in the Docker image. If not specified, it defaults to "dev".
This container is specifically designed to be used as a base image for GitLab CI/CD pipelines. A sample .gitlab-ci.yml file is included in the repository to help you get started.
To use this image in your GitLab CI/CD pipeline, specify it in your .gitlab-ci.yml file:
image: ghcr.io/tschm/ci/ci-image:latest
stages:
- test
- build
- deploy
# Example test job using pytest
test:
stage: test
script:
- python3 -m pytest -v
# More jobs as needed...- Pre-installed tools: Reduces pipeline setup time with Python, Node.js, and common build tools
- Consistent environment: Ensures all CI/CD jobs run in the same environment
- Non-root user: Runs as a non-root user for improved security
- Caching support: Configured for efficient dependency caching in GitLab pipelines
- Use specific version tags (e.g.,
ghcr.io/tschm/ci/ci-image:v1.0.0) rather thanlatestfor reproducible builds - Leverage GitLab CI/CD caching to speed up your pipelines
- Consider extending this image with additional tools specific to your project
The container comes with pre-commit installed and a Git repository initialized in the workspace directory. This allows you to run pre-commit hooks directly:
# Run pre-commit on all files
docker run -it ghcr.io/tschm/ci/ci-image:latest uvx pre-commit run --all-files
# Mount your local directory to use pre-commit on your code
docker run -it -v $(pwd):/workspace ghcr.io/tschm/ci/ci-image:latest bash -c "cd /workspace && uvx pre-commit run --all-files"You can customize the pre-commit configuration by mounting your own .pre-commit-config.yaml file or modifying the default one in the container.