towerops/k8s/base-image/Makefile
Graham McIntire 564caed3e5
refactor: rename base images to gmcintire/towerops-base
Changed image naming scheme from separate builder/runtime images to a
single image name with different tags:

- docker.io/gmcintire/towerops-base:builder
- docker.io/gmcintire/towerops-base:runtime
- docker.io/gmcintire/towerops-base:latest (alias for runtime)

This simplifies the naming and makes it clearer that both images are
part of the same towerops-base image family.

Changes:
- build.sh: Use IMAGE_NAME with BUILDER_TAG/RUNTIME_TAG
- Makefile: Update all targets to use new naming
- k8s/Dockerfile: Point to gmcintire/towerops-base:builder and :runtime
2026-01-25 09:33:42 -06:00

81 lines
3.6 KiB
Makefile

.PHONY: build push test update clean help
# Detect container engine (podman or docker)
CONTAINER_CMD := $(shell command -v podman 2>/dev/null || command -v docker 2>/dev/null)
REGISTRY ?= registry.gitlab.com/towerops/towerops
DOCKERHUB_REGISTRY ?= docker.io/gmcintire
IMAGE_NAME ?= towerops-base
BUILDER_TAG ?= builder
RUNTIME_TAG ?= runtime
ELIXIR_VERSION ?= 1.19.4
OTP_VERSION ?= 28.3
DEBIAN_VERSION ?= trixie-20251229-slim
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 images
@echo "Testing builder image..."
@$(CONTAINER_CMD) run --rm $(REGISTRY)/$(IMAGE_NAME):$(BUILDER_TAG) mix --version
@echo "Testing runtime image..."
@$(CONTAINER_CMD) run --rm $(REGISTRY)/$(IMAGE_NAME):$(RUNTIME_TAG) locale | grep "en_US.UTF-8"
@echo "✅ All tests passed!"
push: ## Push images to GitLab and Docker Hub
@echo "Pushing to GitLab registry..."
@$(CONTAINER_CMD) push $(REGISTRY)/$(IMAGE_NAME):$(BUILDER_TAG)
@$(CONTAINER_CMD) push $(REGISTRY)/$(IMAGE_NAME):$(RUNTIME_TAG)
@$(CONTAINER_CMD) push $(REGISTRY)/$(IMAGE_NAME):latest
@echo "Tagging for Docker Hub..."
@$(CONTAINER_CMD) tag $(REGISTRY)/$(IMAGE_NAME):$(BUILDER_TAG) $(DOCKERHUB_REGISTRY)/$(IMAGE_NAME):$(BUILDER_TAG)
@$(CONTAINER_CMD) tag $(REGISTRY)/$(IMAGE_NAME):$(RUNTIME_TAG) $(DOCKERHUB_REGISTRY)/$(IMAGE_NAME):$(RUNTIME_TAG)
@$(CONTAINER_CMD) tag $(REGISTRY)/$(IMAGE_NAME):latest $(DOCKERHUB_REGISTRY)/$(IMAGE_NAME):latest
@echo "Pushing to Docker Hub..."
@$(CONTAINER_CMD) push $(DOCKERHUB_REGISTRY)/$(IMAGE_NAME):$(BUILDER_TAG)
@$(CONTAINER_CMD) push $(DOCKERHUB_REGISTRY)/$(IMAGE_NAME):$(RUNTIME_TAG)
@$(CONTAINER_CMD) push $(DOCKERHUB_REGISTRY)/$(IMAGE_NAME):latest
pull: ## Pull latest images from registry
@$(CONTAINER_CMD) pull $(REGISTRY)/$(IMAGE_NAME):$(BUILDER_TAG)
@$(CONTAINER_CMD) pull $(REGISTRY)/$(IMAGE_NAME):$(RUNTIME_TAG)
inspect: ## Show image details (size, layers, labels)
@echo "Builder image:"
@$(CONTAINER_CMD) images $(REGISTRY)/$(IMAGE_NAME):$(BUILDER_TAG) --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}\t{{.CreatedAt}}"
@echo ""
@echo "Runtime image:"
@$(CONTAINER_CMD) images $(REGISTRY)/$(IMAGE_NAME):$(RUNTIME_TAG) --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}\t{{.CreatedAt}}"
@echo ""
@echo "Builder labels:"
@$(CONTAINER_CMD) inspect $(REGISTRY)/$(IMAGE_NAME):$(BUILDER_TAG) --format '{{range $$k, $$v := .Config.Labels}}{{$$k}}={{$$v}}{{println}}{{end}}'
@echo ""
@echo "Runtime labels:"
@$(CONTAINER_CMD) inspect $(REGISTRY)/$(IMAGE_NAME):$(RUNTIME_TAG) --format '{{range $$k, $$v := .Config.Labels}}{{$$k}}={{$$v}}{{println}}{{end}}'
clean: ## Remove local images
@$(CONTAINER_CMD) rmi $(REGISTRY)/$(IMAGE_NAME):$(BUILDER_TAG) || true
@$(CONTAINER_CMD) rmi $(REGISTRY)/$(IMAGE_NAME):$(RUNTIME_TAG) || true
@$(CONTAINER_CMD) rmi $(REGISTRY)/$(IMAGE_NAME):latest || true
@$(CONTAINER_CMD) rmi $(DOCKERHUB_REGISTRY)/$(IMAGE_NAME):$(BUILDER_TAG) || true
@$(CONTAINER_CMD) rmi $(DOCKERHUB_REGISTRY)/$(IMAGE_NAME):$(RUNTIME_TAG) || true
@$(CONTAINER_CMD) rmi $(DOCKERHUB_REGISTRY)/$(IMAGE_NAME):latest || true
@echo "✅ Cleaned local images"
login: ## Login to GitLab container registry
@$(CONTAINER_CMD) login registry.gitlab.com
login-dockerhub: ## Login to Docker Hub
@$(CONTAINER_CMD) login docker.io
# Quick commands
b: build ## Shortcut for build
t: test ## Shortcut for test
p: push ## Shortcut for push