This repository has been archived on 2025-07-06. You can view files and clone it, but cannot push or open issues or pull requests.
docker-almalinux-jupyterins.../Makefile
Ben Vincent 0f2d2b49ca
All checks were successful
Build / build (pull_request) Successful in 44s
feat: makefile advancements
- add test target
- update clean target
2024-11-16 19:09:23 +11:00

38 lines
1.3 KiB
Makefile

# Get the current Git commit hash
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) .
# 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
# 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
# Clean up dangling Docker 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
# Default target
default: build