fix: podman

- Use podman as container runtime.
- Add podman into build-image.
- Adapt Makefile to use fully qualified instead of unqualified container
  image names.
This commit is contained in:
Markus Pesch 2021-03-05 22:09:41 +01:00
parent fbdc3816ed
commit 40e51db36d
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
3 changed files with 31 additions and 44 deletions

View File

@ -6,7 +6,7 @@ steps:
- name: build-image-latest
image: docker.io/volkerraschek/build-image:latest
commands:
- make container-image/build
- make CONTAINER_RUNTIME=docker container-image/build
volumes:
- name: docker_socket
path: /var/run/docker.sock
@ -17,7 +17,7 @@ steps:
- name: push-image-latest
image: docker.io/volkerraschek/build-image:latest
commands:
- make container-image/push
- make CONTAINER_RUNTIME=docker container-image/push
environment:
CONTAINER_IMAGE_REGISTRY_PASSWORD:
from_secret: container_image_registry_password
@ -31,21 +31,7 @@ steps:
- name: delete-image-latest
image: docker.io/volkerraschek/build-image:latest
commands:
- make container-image/delete
volumes:
- name: docker_socket
path: /var/run/docker.sock
when:
branch:
- master
- name: push-readme
image: docker.io/volkerraschek/build-image:latest
commands:
- make push/README
environment:
CONTAINER_IMAGE_REGISTRY_PASSWORD:
from_secret: container_image_registry_password
- make CONTAINER_RUNTIME=docker container-image/delete
volumes:
- name: docker_socket
path: /var/run/docker.sock

View File

@ -5,7 +5,17 @@ FROM ${BASE_IMAGE}
RUN pacman --sync \
--refresh \
--noconfirm \
--sysupgrade awk bash-completion docker go gcc make git which zip
--sysupgrade \
awk \
bash-completion \
docker \
gcc \
git \
go \
make \
podman \
which \
zip
COPY installation-scripts /tmp/installation-scripts

View File

@ -1,65 +1,56 @@
# 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 docker)
CONTAINER_RUNTIME?=$(shell which podman)
# BASE_IMAGE
# Defines the name of the container base image on which should be built the new
# CONTAINER_IMAGE.
BASE_IMAGE_REGISTRY_NAME:=docker.io
BASE_IMAGE_REGISTRY_HOST:=docker.io
BASE_IMAGE_NAMESPACE:=archlinux
BASE_IMAGE_NAME:=base
BASE_IMAGE_REPOSITORY:=base
BASE_IMAGE_VERSION:=latest
BASE_IMAGE_FULL=${BASE_IMAGE_REGISTRY_NAME}/${BASE_IMAGE_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_IMAGE_VERSION}
BASE_IMAGE_SHORT=${BASE_IMAGE_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_IMAGE_VERSION}
BASE_IMAGE_FULLY_QUALIFIED=${BASE_IMAGE_REGISTRY_HOST}/${BASE_IMAGE_NAMESPACE}/${BASE_IMAGE_REPOSITORY}:${BASE_IMAGE_VERSION}
# CONTAINER_IMAGE_REGISTRY_NAME
# CONTAINER_IMAGE
# Defines the name of the new container to be built using several variables.
CONTAINER_IMAGE_REGISTRY_NAME:=docker.io
CONTAINER_IMAGE_REGISTRY_HOST:=docker.io
CONTAINER_IMAGE_REGISTRY_USER:=volkerraschek
CONTAINER_IMAGE_NAMESPACE?=${CONTAINER_IMAGE_REGISTRY_USER}
CONTAINER_IMAGE_NAME:=build-image
CONTAINER_IMAGE_REPOSITORY:=build-image
CONTAINER_IMAGE_VERSION?=latest
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}
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
# ==============================================================================
PHONY:=container-image/build
container-image/build:
${CONTAINER_RUNTIME} build \
--build-arg BASE_IMAGE=${BASE_IMAGE_FULL} \
--build-arg BASE_IMAGE=${BASE_IMAGE_FULLY_QUALIFIED} \
--file Dockerfile \
--no-cache \
--pull \
--tag ${CONTAINER_IMAGE_FULL} \
--tag ${CONTAINER_IMAGE_SHORT} \
--tag ${CONTAINER_IMAGE_FULLY_QUALIFIED} \
--tag ${CONTAINER_IMAGE_UNQUALIFIED} \
.
# 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}
- ${CONTAINER_RUNTIME} image rm ${CONTAINER_IMAGE_FULLY_QUALIFIED} ${CONTAINER_IMAGE_UNQUALIFIED}
- ${CONTAINER_RUNTIME} image rm ${BASE_IMAGE_FULLY_QUALIFIED}
# PUSH CONTAINER IMAGE
# ==============================================================================
PHONY+=container-image/push
container-image/push:
echo ${CONTAINER_IMAGE_REGISTRY_PASSWORD} | ${CONTAINER_RUNTIME} login ${CONTAINER_IMAGE_REGISTRY_NAME} --username ${CONTAINER_IMAGE_REGISTRY_USER} --password-stdin
${CONTAINER_RUNTIME} push ${CONTAINER_IMAGE_FULL}
# 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}
${CONTAINER_RUNTIME} login ${CONTAINER_IMAGE_REGISTRY_HOST} --username ${CONTAINER_IMAGE_REGISTRY_USER} --password ${CONTAINER_IMAGE_REGISTRY_PASSWORD}
${CONTAINER_RUNTIME} push ${CONTAINER_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}
.PHONY: ${PHONY}