Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 14, 2025. It is now read-only.

tschm/ci

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI/CD Container

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.

Features

  • 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

GitHub Workflows

Docker Image Build and Publish

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:

  1. The workflow runs automatically when changes are made to the Dockerfile
  2. You can manually trigger it from the Actions tab in GitHub
  3. 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)
  4. 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

Release Workflow

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: write permission to push images to GitHub Container Registry

To use the release workflow:

  1. Go to the Actions tab in GitHub and select the "Release Workflow"
  2. Click "Run workflow" and enter a release tag (e.g., v1.2.3)
  3. The workflow will create the Git tag, build and publish the Docker image, and create a GitHub release
  4. The Docker image will be available at ghcr.io/{repository}/ci-image:{tag} and can be pulled with docker pull ghcr.io/{repository}/ci-image:{tag}
  5. The GitHub release will include a section with the Docker image URL and pull command

Building Locally

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".

Using with GitLab CI/CD

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.

Sample GitLab CI/CD Configuration

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...

Benefits for GitLab CI/CD

  • 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

Best Practices

  1. Use specific version tags (e.g., ghcr.io/tschm/ci/ci-image:v1.0.0) rather than latest for reproducible builds
  2. Leverage GitLab CI/CD caching to speed up your pipelines
  3. Consider extending this image with additional tools specific to your project

Using Pre-commit

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.

About

ci/cd container

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •