towerops/k8s/base-image/QUICKSTART.md
Graham McIntire 8f87d4bbab
feat: add custom minimal Debian base image build system
Created build system for minimal Debian 13 (Trixie) image with Erlang/OTP
and Elixir runtime pre-installed. This will speed up CI/CD builds by caching
the runtime environment.

Features:
- Multi-stage Dockerfile for minimal final image (~150-200 MB)
- Build script with automatic tagging (versioned, latest, dated)
- Update script for easy security patch rebuilds
- Makefile for common operations
- Comprehensive documentation (README + QUICKSTART)

Benefits:
- Faster CI/CD: Saves 30-60s per build (no apt-get install runtime deps)
- Smaller images: Only essential runtime packages included
- Security: Easy to rebuild weekly/monthly with latest patches
- Consistency: Same runtime across all environments

Usage:
  cd k8s/base-image
  make build    # Build the image
  make test     # Verify it works
  make push     # Push to registry

Then update k8s/Dockerfile to use the custom base image.

This replaces the previous Dockerfile.base approach with a more
comprehensive and maintainable build system.
2026-01-25 09:07:55 -06:00

1.9 KiB

Quick Start Guide

One-Time Setup

cd k8s/base-image

# Login to GitLab registry
docker login registry.gitlab.com

# Build the base image
make build

# Test it works
make test

# Push to registry
make push

Update Main Dockerfile

Edit k8s/Dockerfile:

# Change this line:
ARG RUNNER_IMAGE="docker.io/debian:${DEBIAN_VERSION}"

# To this:
ARG RUNNER_IMAGE="registry.gitlab.com/towerops/towerops/elixir-runtime:28.3-elixir-1.19.5-debian-trixie"

Remove these lines (already in base image):

# DELETE THESE:
RUN apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
    && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
       libstdc++6 openssl libncurses6 locales ca-certificates iputils-ping \
    && rm -rf /var/lib/apt/lists/*

RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
    && locale-gen

ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8

WORKDIR "/app"
RUN chown nobody /app

Weekly/Monthly Maintenance

# Rebuild with latest security updates
cd k8s/base-image
make update
make push

Common Commands

make help          # Show all commands
make build         # Build base image
make test          # Test base image
make push          # Push to registry
make inspect       # Show image details
make clean         # Remove local images

Expected Results

  • Build time: 2-3 minutes (first time)
  • Image size: ~150-200 MB
  • CI/CD speedup: 30-60 seconds saved per build

Troubleshooting

Build fails:

# Try with verbose output
docker build --progress=plain --no-cache -f Dockerfile .

Can't push to registry:

# Re-login
docker login registry.gitlab.com

Application crashes with missing library:

# Add to Dockerfile, then rebuild
RUN apt-get install -y your-package
make build && make push