Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Docker Base Images

Build and Push Images Scheduled Build

Professional collection of production-ready Docker base images with a clean, declarative build system.

Overview

This repository provides curated Docker base images for various use cases, built with a focus on:

  • Security: Regular updates, security scanning, and minimal attack surface
  • Consistency: Reproducible builds with declarative configuration
  • Maintainability: Single source of truth, no duplicated logic
  • Simplicity: Easy to understand, easy to extend
  • Multi-version Support: Build matrices for multiple versions of dependencies

πŸ—οΈ Architecture

BaseImages/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       β”œβ”€β”€ build.yml           # Orchestrator: dispatches per-image builds
β”‚       β”œβ”€β”€ build-image.yml     # Reusable: builds one image (all variants)
β”‚       β”œβ”€β”€ scan-image.yml      # Reusable: Trivy scan for one image
β”‚       β”œβ”€β”€ validate-image.yml  # Reusable: PR validation for one image
β”‚       β”œβ”€β”€ pr-validate.yml     # PR orchestrator
β”‚       └── scheduled.yml       # Scheduled orchestrator
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ generate-matrix.py      # Generates build matrix from config
β”‚   β”œβ”€β”€ list-images.py          # Lists image names for orchestrators
β”‚   β”œβ”€β”€ detect-changed-images.py # Maps file changes to images
β”‚   └── validate-config.py      # Validates configuration
β”œβ”€β”€ images/
β”‚   β”œβ”€β”€ ml/
β”‚   β”‚   β”œβ”€β”€ pytorch/
β”‚   β”‚   β”‚   β”œβ”€β”€ Dockerfile   # PyTorch image definition
β”‚   β”‚   β”‚   β”œβ”€β”€ test.sh      # Image tests
β”‚   β”‚   β”‚   └── README.md    # PyTorch image documentation
β”‚   β”‚   └── tensorflow/
β”‚   β”‚       β”œβ”€β”€ Dockerfile   # TensorFlow image definition
β”‚   β”‚       β”œβ”€β”€ test.sh      # Image tests
β”‚   β”‚       └── README.md    # TensorFlow image documentation
β”‚   └── languages/
β”‚       β”œβ”€β”€ python/
β”‚       β”‚   β”œβ”€β”€ Dockerfile   # Python image definition
β”‚       β”‚   β”œβ”€β”€ test.sh      # Image tests
β”‚       β”‚   └── README.md    # Python image documentation
β”‚       └── golang/
β”‚           β”œβ”€β”€ Dockerfile   # Golang image definition
β”‚           β”œβ”€β”€ test.sh      # Image tests
β”‚           └── README.md    # Golang image documentation
β”œβ”€β”€ images.yaml              # Centralized configuration
β”œβ”€β”€ CONTRIBUTING.md          # How to add or update images
└── README.md

πŸ“¦ Available Images

Image Description
PyTorch Production-ready PyTorch base image with CUDA support
TensorFlow Production-ready TensorFlow base image with CUDA support
Python Lightweight Python base image for general-purpose development
Golang Lightweight Golang base image for development and production

Images are published to Docker Hub under the devopshobbies namespace (e.g. devopshobbies/pytorch). See each image's README for versions, tags, and pull instructions.

πŸ”„ CI/CD Workflows

Build Workflow (build.yml)

Triggered on:

  • Push to main branch (builds only changed images)
  • Manual dispatch with options
  • Called by other workflows

Architecture:

  • Orchestrator (build.yml) plans which images to build from images.yaml
  • Per-image pipeline (build-image.yml) runs each image in an isolated workflow with its own runners and disk space
  • Variant builds within one image run sequentially (max-parallel: 1) to avoid disk exhaustion on large images

Features:

  • Dynamic build matrix from images.yaml
  • Multi-architecture support where configured (defaults amd64+arm64; ML images currently amd64)
  • Per-image GHA cache scopes
  • Automatic testing
  • Push to Docker Hub (devopshobbies namespace)

Note: Pushing to Docker Hub requires the repository secret DOCKERHUB_TOKEN (a Docker Hub access token) to be configured under Settings β†’ Secrets and variables β†’ Actions. The Docker Hub username is taken from the IMAGE_NAMESPACE workflow variable.

Scheduled Build (scheduled.yml)

Runs weekly (Sundays at 2:00 AM UTC). For each image in images.yaml:

  • Pre-build security scan (isolated runner)
  • Rebuild via build-image.yml (isolated runner)
  • Post-build security scan (isolated runner)
  • Summary report

PR Validation (pr-validate.yml)

Triggered on pull requests. Performs:

  • YAML linting
  • Dockerfile linting (hadolint)
  • Configuration validation
  • Per-image build test via validate-image.yml (isolated runner)
  • Security scanning (Trivy)

πŸ› οΈ Adding a New Image

See CONTRIBUTING.md for the full guide (directory layout, Dockerfile conventions, images.yaml registration, tests, and PR checklist).

πŸ”§ Local Development

Build locally

# Build PyTorch image
docker build -t pytorch:local images/ml/pytorch/

# Build with specific versions
docker build \
  --build-arg CUDA_VERSION=12.4 \
  --build-arg PYTHON_VERSION=3.11 \
  --build-arg PYTORCH_VERSION=2.4 \
  -t pytorch:local images/ml/pytorch/

Run tests locally

docker run --rm pytorch:local /bin/bash -c "$(cat images/ml/pytorch/test.sh)"

Generate build matrix

pip install pyyaml
python scripts/generate-matrix.py --config images.yaml --image all
python scripts/generate-matrix.py --config images.yaml --image pytorch --defaults-only

List images / detect changes

python scripts/list-images.py --config images.yaml
python scripts/detect-changed-images.py --config images.yaml < changed-files.txt

Validate configuration

python scripts/validate-config.py --config images.yaml

πŸ“‹ Configuration Reference

images.yaml Structure

settings:
  registry: docker.io
  organization: devopshobbies
  default_platforms:
    - linux/amd64
    - linux/arm64

images:
  image-name:
    path: path/to/dockerfile      # Required
    description: "Description"     # Optional
    versions:                      # Version matrix
      component1: ["v1", "v2"]
      component2: ["a", "b"]
    defaults:                      # For 'latest' tag
      component1: "v2"
      component2: "b"
    build_args:                    # Docker build args
      ARG_NAME: component1
    platforms:                     # Override default platforms
      - linux/amd64
    tags:
      pattern: "name-{component1}-{component2}"
      include_latest: true
    test:
      enabled: true
      script: "test.sh"
      timeout: 300

πŸ” Security

  • Weekly rebuilds: All images are rebuilt weekly to incorporate security patches
  • Vulnerability scanning: Trivy scans on every PR and scheduled build
  • Non-root users: Images include non-root user option
  • Minimal attack surface: Only essential packages installed
  • SBOM generation: Planned (not yet implemented)

License

See LICENSE file for details.

Contributing

Contributions are welcome. See CONTRIBUTING.md for how to add or update images, then open an issue or pull request.

About

Production-ready Docker base images

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages