Enhanced base image build system with: Container Engine Support: - Auto-detect podman or docker (prefers podman if both installed) - All scripts work with either engine seamlessly - No configuration needed Docker Hub Integration: - Push to both GitLab and Docker Hub registries - GitLab: registry.gitlab.com/towerops/towerops/elixir-runtime - Docker Hub: docker.io/gmcintire/elixir-runtime - Both versioned and :latest tags pushed to each Build Script: - Detect and use $CONTAINER_CMD for all operations - Show which container engine is being used in output - Tag and push to both registries automatically Makefile: - Add CONTAINER_CMD variable with auto-detection - Add DOCKERHUB_REGISTRY configuration - Update all targets to use detected container engine - Add login-dockerhub target for Docker Hub authentication - Update push target to push to both registries Documentation: - Document podman/docker auto-detection - Update login instructions for both registries - Update troubleshooting with examples for both engines This makes the build system more flexible and accessible to users who prefer podman over docker, while also publishing to the public Docker Hub registry for easier access.
69 lines
2.8 KiB
Makefile
69 lines
2.8 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 ?= 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..."
|
|
@$(CONTAINER_CMD) run --rm $(REGISTRY)/$(IMAGE_NAME):latest erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell
|
|
@echo "Testing Elixir..."
|
|
@$(CONTAINER_CMD) run --rm $(REGISTRY)/$(IMAGE_NAME):latest elixir --version
|
|
@echo "Testing locale..."
|
|
@$(CONTAINER_CMD) run --rm $(REGISTRY)/$(IMAGE_NAME):latest locale
|
|
@echo "✅ All tests passed!"
|
|
|
|
push: ## Push image to GitLab and Docker Hub
|
|
@echo "Pushing to GitLab registry..."
|
|
@$(CONTAINER_CMD) push $(REGISTRY)/$(IMAGE_NAME):$(TAG)
|
|
@$(CONTAINER_CMD) push $(REGISTRY)/$(IMAGE_NAME):latest
|
|
@echo "Tagging for Docker Hub..."
|
|
@$(CONTAINER_CMD) tag $(REGISTRY)/$(IMAGE_NAME):$(TAG) $(DOCKERHUB_REGISTRY)/$(IMAGE_NAME):$(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):$(TAG)
|
|
@$(CONTAINER_CMD) push $(DOCKERHUB_REGISTRY)/$(IMAGE_NAME):latest
|
|
|
|
pull: ## Pull latest image from registry
|
|
@$(CONTAINER_CMD) pull $(REGISTRY)/$(IMAGE_NAME):latest
|
|
|
|
inspect: ## Show image details (size, layers, labels)
|
|
@echo "Image size:"
|
|
@$(CONTAINER_CMD) images $(REGISTRY)/$(IMAGE_NAME):latest --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}\t{{.CreatedAt}}"
|
|
@echo ""
|
|
@echo "Image labels:"
|
|
@$(CONTAINER_CMD) inspect $(REGISTRY)/$(IMAGE_NAME):latest --format '{{range $$k, $$v := .Config.Labels}}{{$$k}}={{$$v}}{{println}}{{end}}'
|
|
|
|
clean: ## Remove local images
|
|
@$(CONTAINER_CMD) rmi $(REGISTRY)/$(IMAGE_NAME):$(TAG) || true
|
|
@$(CONTAINER_CMD) rmi $(REGISTRY)/$(IMAGE_NAME):latest || true
|
|
@$(CONTAINER_CMD) rmi $(DOCKERHUB_REGISTRY)/$(IMAGE_NAME):$(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
|