build-image/Makefile

57 lines
2.4 KiB
Makefile
Raw Normal View History

# CONTAINER_RUNTIME
# The CONTAINER_RUNTIME variable will be used to specified the path to a
2020-06-06 15:24:05 +00:00
# container runtime. This is needed to start and run a container image.
CONTAINER_RUNTIME?=$(shell which podman)
2020-06-06 15:24:05 +00:00
# BASE_IMAGE
# Defines the name of the container base image on which should be built the new
# CONTAINER_IMAGE.
BASE_IMAGE_REGISTRY_HOST:=docker.io
2020-06-06 15:24:05 +00:00
BASE_IMAGE_NAMESPACE:=archlinux
BASE_IMAGE_REPOSITORY:=base
2020-06-06 15:24:05 +00:00
BASE_IMAGE_VERSION:=latest
BASE_IMAGE_FULLY_QUALIFIED=${BASE_IMAGE_REGISTRY_HOST}/${BASE_IMAGE_NAMESPACE}/${BASE_IMAGE_REPOSITORY}:${BASE_IMAGE_VERSION}
2020-06-06 15:24:05 +00:00
# CONTAINER_IMAGE
2020-06-06 15:24:05 +00:00
# Defines the name of the new container to be built using several variables.
CONTAINER_IMAGE_REGISTRY_HOST:=docker.io
2020-06-06 15:24:05 +00:00
CONTAINER_IMAGE_REGISTRY_USER:=volkerraschek
CONTAINER_IMAGE_NAMESPACE?=${CONTAINER_IMAGE_REGISTRY_USER}
CONTAINER_IMAGE_REPOSITORY:=build-image
2020-06-06 15:24:05 +00:00
CONTAINER_IMAGE_VERSION?=latest
CONTAINER_IMAGE_FULLY_QUALIFIED=${CONTAINER_IMAGE_REGISTRY_HOST}/${CONTAINER_IMAGE_NAMESPACE}/${CONTAINER_IMAGE_REPOSITORY}:${CONTAINER_IMAGE_VERSION}
CONTAINER_IMAGE_UNQUALIFIED=${CONTAINER_IMAGE_NAMESPACE}/${CONTAINER_IMAGE_REPOSITORY}:${CONTAINER_IMAGE_VERSION}
# BUILD CONTAINER IMAGE
# ==============================================================================
2020-06-06 15:24:05 +00:00
PHONY:=container-image/build
container-image/build:
${CONTAINER_RUNTIME} build \
--build-arg BASE_IMAGE=${BASE_IMAGE_FULLY_QUALIFIED} \
--file Dockerfile \
--no-cache \
2020-06-06 15:24:05 +00:00
--pull \
--tag ${CONTAINER_IMAGE_FULLY_QUALIFIED} \
--tag ${CONTAINER_IMAGE_UNQUALIFIED} \
2019-04-18 15:33:44 +00:00
.
# DELETE CONTAINER IMAGE
# ==============================================================================
PHONY:=container-image/delete
container-image/delete:
- ${CONTAINER_RUNTIME} image rm ${CONTAINER_IMAGE_FULLY_QUALIFIED} ${CONTAINER_IMAGE_UNQUALIFIED}
- ${CONTAINER_RUNTIME} image rm ${BASE_IMAGE_FULLY_QUALIFIED}
# PUSH CONTAINER IMAGE
# ==============================================================================
2020-06-06 15:24:05 +00:00
PHONY+=container-image/push
container-image/push:
${CONTAINER_RUNTIME} login ${CONTAINER_IMAGE_REGISTRY_HOST} --username ${CONTAINER_IMAGE_REGISTRY_USER} --password ${CONTAINER_IMAGE_REGISTRY_PASSWORD}
${CONTAINER_RUNTIME} push ${CONTAINER_IMAGE_FULLY_QUALIFIED}
2021-01-09 11:48:37 +00:00
# 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}