feat: enable multirelease
Build / build (pull_request) Successful in 2m8s

- manage almalinux 8 and 9 deployments
This commit is contained in:
2024-12-20 20:39:03 +11:00
parent 6fe441a9c9
commit ac7bafa7b3
3 changed files with 77 additions and 23 deletions
+34 -23
View File
@@ -1,37 +1,48 @@
# Get the current Git commit hash
# Variables
GIT_COMMIT := $(shell git rev-parse --short HEAD)
# Get the current date in YYYYMMDD format
DATE_TAG := $(shell date +%Y%m%d)
# Set the Docker image name and repository information
IMAGE_NAME := almalinux8-jupyterinstance
REGISTRY := git.query.consul
OWNER := unkin
# Build the Docker image (without tags)
build:
docker build --network=host -t $(REGISTRY)/$(OWNER)/$(IMAGE_NAME) .
# List of releases (directories under ./release)
RELEASES := $(shell find release -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
# Tag the Docker image with the Git commit hash, the date, and 'latest'
tag:
docker tag $(REGISTRY)/$(OWNER)/$(IMAGE_NAME) $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(GIT_COMMIT)
docker tag $(REGISTRY)/$(OWNER)/$(IMAGE_NAME) $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(DATE_TAG)
docker tag $(REGISTRY)/$(OWNER)/$(IMAGE_NAME) $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):latest
# Build all releases
build: $(addprefix build-,$(RELEASES))
# Push the Docker image to a repository with all tags
push: tag
docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(GIT_COMMIT)
docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(DATE_TAG)
docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):latest
# Tag all releases
tag: $(addprefix tag-,$(RELEASES))
# Clean up dangling Docker images
# Push all releases
push: $(addprefix push-,$(RELEASES))
# Clean dangling images
clean:
docker image prune -f
sudo docker rm jupyterinstance
test:
sudo docker run -it --name jupyterinstance --entrypoint /bin/bash -v jupyterhub-test:/home/jupyter/work $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):latest
# List all available releases
list:
@echo "Available releases:"
@echo $(RELEASES) | tr ' ' '\n'
# Build a specific release
build-%:
$(info Building almalinux$*-jupyterinstance Docker image)
docker build --network=host -t $(REGISTRY)/$(OWNER)/almalinux$*-jupyterinstance -f release/$*/Dockerfile release/$*
# Tag a specific release
tag-%:
$(info Tagging almalinux$*-jupyterinstance Docker image)
docker tag $(REGISTRY)/$(OWNER)/almalinux$*-jupyterinstance $(REGISTRY)/$(OWNER)/almalinux$*-jupyterinstance:$(GIT_COMMIT)
docker tag $(REGISTRY)/$(OWNER)/almalinux$*-jupyterinstance $(REGISTRY)/$(OWNER)/almalinux$*-jupyterinstance:$(DATE_TAG)
docker tag $(REGISTRY)/$(OWNER)/almalinux$*-jupyterinstance $(REGISTRY)/$(OWNER)/almalinux$*-jupyterinstance:latest
# Push a specific release
push-%: tag-%
$(info Pushing almalinux$*-jupyterinstance Docker image)
docker push $(REGISTRY)/$(OWNER)/almalinux$*-jupyterinstance:$(GIT_COMMIT)
docker push $(REGISTRY)/$(OWNER)/almalinux$*-jupyterinstance:$(DATE_TAG)
docker push $(REGISTRY)/$(OWNER)/almalinux$*-jupyterinstance:latest
# Default target
default: build