2020-03-13 12:20:53 +00:00
|
|
|
# CONTAINER_RUNTIME
|
2020-06-06 17:05:16 +00:00
|
|
|
# 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 docker)
|
2020-03-13 12:20:53 +00:00
|
|
|
|
|
|
|
# BASE_IMAGE
|
2020-06-06 17:05:16 +00:00
|
|
|
# Defines the name of the container base image on which should be built the new
|
|
|
|
# CONTAINER_IMAGE.
|
|
|
|
BASE_IMAGE_REGISTRY_NAME:=docker.io
|
2020-03-13 12:20:53 +00:00
|
|
|
BASE_IMAGE_NAMESPACE:=library
|
|
|
|
BASE_IMAGE_NAME:=alpine
|
|
|
|
BASE_IMAGE_VERSION:=3.11.2
|
2020-06-06 17:05:16 +00:00
|
|
|
BASE_IMAGE_FULL=${BASE_IMAGE_REGISTRY_NAME}/${BASE_IMAGE_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_IMAGE_VERSION}
|
2020-03-13 12:20:53 +00:00
|
|
|
BASE_IMAGE_SHORT=${BASE_IMAGE_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_IMAGE_VERSION}
|
|
|
|
|
2020-06-06 17:05:16 +00:00
|
|
|
# CONTAINER_IMAGE_REGISTRY_NAME
|
|
|
|
# Defines the name of the new container to be built using several variables.
|
|
|
|
CONTAINER_IMAGE_REGISTRY_NAME:=docker.io
|
2020-03-13 12:20:53 +00:00
|
|
|
CONTAINER_IMAGE_REGISTRY_USER:=volkerraschek
|
2020-06-06 17:05:16 +00:00
|
|
|
|
|
|
|
CONTAINER_IMAGE_NAMESPACE?=${CONTAINER_IMAGE_REGISTRY_USER}
|
2021-01-08 15:53:49 +00:00
|
|
|
CONTAINER_IMAGE_NAME:=network-tools
|
2020-03-13 12:20:53 +00:00
|
|
|
CONTAINER_IMAGE_VERSION?=latest
|
2020-06-06 17:05:16 +00:00
|
|
|
CONTAINER_IMAGE_FULL=${CONTAINER_IMAGE_REGISTRY_NAME}/${CONTAINER_IMAGE_NAMESPACE}/${CONTAINER_IMAGE_NAME}:${CONTAINER_IMAGE_VERSION}
|
|
|
|
CONTAINER_IMAGE_SHORT=${CONTAINER_IMAGE_NAMESPACE}/${CONTAINER_IMAGE_NAME}:${CONTAINER_IMAGE_VERSION}
|
2020-03-13 12:20:53 +00:00
|
|
|
|
2020-06-06 17:05:16 +00:00
|
|
|
# BUILD CONTAINER IMAGE
|
2020-03-13 12:20:53 +00:00
|
|
|
# ==============================================================================
|
2020-06-06 17:05:16 +00:00
|
|
|
PHONY:=container-image/build
|
2020-03-13 12:20:53 +00:00
|
|
|
container-image/build:
|
|
|
|
${CONTAINER_RUNTIME} build \
|
|
|
|
--build-arg BASE_IMAGE=${BASE_IMAGE_FULL} \
|
2020-06-06 17:05:16 +00:00
|
|
|
--file Dockerfile \
|
2020-03-13 12:20:53 +00:00
|
|
|
--no-cache \
|
2020-06-06 17:05:16 +00:00
|
|
|
--pull \
|
2020-03-13 12:20:53 +00:00
|
|
|
--tag ${CONTAINER_IMAGE_FULL} \
|
|
|
|
--tag ${CONTAINER_IMAGE_SHORT} \
|
|
|
|
.
|
|
|
|
|
2021-01-08 15:53:49 +00:00
|
|
|
# DELETE CONTAINER IMAGE
|
|
|
|
# ==============================================================================
|
|
|
|
PHONY:=container-image/delete
|
|
|
|
container-image/delete:
|
|
|
|
- ${CONTAINER_RUNTIME} image rm ${CONTAINER_IMAGE_FULL} ${CONTAINER_IMAGE_SHORT}
|
|
|
|
- ${CONTAINER_RUNTIME} image rm ${BASE_IMAGE_FULL}
|
|
|
|
|
2020-06-06 17:05:16 +00:00
|
|
|
# PUSH CONTAINER IMAGE
|
|
|
|
# ==============================================================================
|
2020-03-13 12:20:53 +00:00
|
|
|
PHONY+=container-image/push
|
2020-06-06 17:05:16 +00:00
|
|
|
container-image/push:
|
|
|
|
echo ${CONTAINER_IMAGE_REGISTRY_PASSWORD} | ${CONTAINER_RUNTIME} login ${CONTAINER_IMAGE_REGISTRY_NAME} --username ${CONTAINER_IMAGE_REGISTRY_USER} --password-stdin
|
2020-03-13 12:20:53 +00:00
|
|
|
${CONTAINER_RUNTIME} push ${CONTAINER_IMAGE_FULL}
|
|
|
|
|
2021-01-09 12:03:00 +00:00
|
|
|
# PUSH README
|
|
|
|
# ==============================================================================
|
|
|
|
PHONY+=push/README
|
|
|
|
push/README:
|
|
|
|
echo ${CONTAINER_IMAGE_REGISTRY_PASSWORD} | ${CONTAINER_RUNTIME} login ${CONTAINER_IMAGE_REGISTRY_NAME} --username ${CONTAINER_IMAGE_REGISTRY_USER} --password-stdin
|
|
|
|
docker pushrm ${CONTAINER_IMAGE_FULL}
|
|
|
|
|
2020-03-13 12:20:53 +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}
|