towerops/k8s/base-image/Makefile
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

53 lines
1.9 KiB
Makefile

.PHONY: build push test update clean help
REGISTRY ?= registry.gitlab.com/towerops/towerops
IMAGE_NAME ?= elixir-runtime
ERLANG_VERSION ?= 28.3
ELIXIR_VERSION ?= 1.19.5
TAG ?= $(ERLANG_VERSION)-elixir-$(ELIXIR_VERSION)-debian-trixie
help: ## Show this help message
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
build: ## Build the base image with latest packages
@chmod +x build.sh
@./build.sh
update: build ## Alias for build (rebuilds with latest packages)
test: ## Test the built image
@echo "Testing Erlang..."
@docker run --rm $(REGISTRY)/$(IMAGE_NAME):latest erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell
@echo "Testing Elixir..."
@docker run --rm $(REGISTRY)/$(IMAGE_NAME):latest elixir --version
@echo "Testing locale..."
@docker run --rm $(REGISTRY)/$(IMAGE_NAME):latest locale
@echo "✅ All tests passed!"
push: ## Push image to registry
@docker push $(REGISTRY)/$(IMAGE_NAME):$(TAG)
@docker push $(REGISTRY)/$(IMAGE_NAME):latest
pull: ## Pull latest image from registry
@docker pull $(REGISTRY)/$(IMAGE_NAME):latest
inspect: ## Show image details (size, layers, labels)
@echo "Image size:"
@docker images $(REGISTRY)/$(IMAGE_NAME):latest --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}\t{{.CreatedAt}}"
@echo ""
@echo "Image labels:"
@docker inspect $(REGISTRY)/$(IMAGE_NAME):latest --format '{{range $$k, $$v := .Config.Labels}}{{$$k}}={{$$v}}{{println}}{{end}}'
clean: ## Remove local images
@docker rmi $(REGISTRY)/$(IMAGE_NAME):$(TAG) || true
@docker rmi $(REGISTRY)/$(IMAGE_NAME):latest || true
@echo "✅ Cleaned local images"
login: ## Login to GitLab container registry
@docker login registry.gitlab.com
# Quick commands
b: build ## Shortcut for build
t: test ## Shortcut for test
p: push ## Shortcut for push