git-docker/Makefile
2023-10-01 18:54:37 +02:00

47 lines
1.9 KiB
Makefile

# CONTAINER_RUNTIME
# The CONTAINER_RUNTIME variable will be used to specified the path to a
# container runtime. This is needed to start and run a container image.
CONTAINER_RUNTIME?=$(shell which podman)
# GIT_IMAGE_REGISTRY_NAME
# Defines the name of the new container to be built using several variables.
GIT_IMAGE_REGISTRY_NAME:=git.cryptic.systems
GIT_IMAGE_REGISTRY_USER:=volker.raschek
GIT_IMAGE_NAMESPACE?=${GIT_IMAGE_REGISTRY_USER}
GIT_IMAGE_NAME:=git
GIT_IMAGE_VERSION?=latest
GIT_IMAGE_FULLY_QUALIFIED=${GIT_IMAGE_REGISTRY_NAME}/${GIT_IMAGE_NAMESPACE}/${GIT_IMAGE_NAME}:${GIT_IMAGE_VERSION}
GIT_IMAGE_UNQUALIFIED=${GIT_IMAGE_NAMESPACE}/${GIT_IMAGE_NAME}:${GIT_IMAGE_VERSION}
# BUILD CONTAINER IMAGE
# ==============================================================================
PHONY:=container-image/build
container-image/build:
${CONTAINER_RUNTIME} build \
--file Dockerfile \
--no-cache \
--pull \
--tag ${GIT_IMAGE_FULLY_QUALIFIED} \
--tag ${GIT_IMAGE_UNQUALIFIED} \
.
# DELETE CONTAINER IMAGE
# ==============================================================================
PHONY:=container-image/delete
container-image/delete:
- ${CONTAINER_RUNTIME} image rm ${GIT_IMAGE_FULLY_QUALIFIED} ${GIT_IMAGE_UNQUALIFIED}
- ${CONTAINER_RUNTIME} image rm ${BASE_IMAGE_FULL}
# PUSH CONTAINER IMAGE
# ==============================================================================
PHONY+=container-image/push
container-image/push:
echo ${GIT_IMAGE_REGISTRY_PASSWORD} | ${CONTAINER_RUNTIME} login ${GIT_IMAGE_REGISTRY_NAME} --username ${GIT_IMAGE_REGISTRY_USER} --password-stdin
${CONTAINER_RUNTIME} push ${GIT_IMAGE_FULLY_QUALIFIED}
# PHONY
# ==============================================================================
# Declare the contents of the PHONY variable as phony. We keep that information
# in a variable so we can use it in if_changed.
.PHONY: ${PHONY}