Skip to content

Commit

Permalink
Use podman instead of docker when available
Browse files Browse the repository at this point in the history
Docker introduced BuildKit in 2017, and made it default on Linux in
2023. BuildKit requires completely new API during client-server
communication. docker-py Python bindings is communicating with server
directly, and has not been made aware of this new API - see
docker/docker-py#2230 .

To fix DISCOVERY-435, we wanted to use build-time secrets. This feature
requires BuildKit, and therefore is not available in pytest unit tests
that use docker-py library.

To workaround this problem, we use DOCKER_HOST variable pointing to
podman socket file. Podman is compatible with old Docker API, but still
supports some of newer build features provided by BuildKit. This way we
can use build-time secrets while still using old API.

Podman will be used only if podman is installed and socket file exists.
Developers without podman should not need to change their system,
although they will notice failures in `make test-integration`.
  • Loading branch information
mirekdlugosz committed Oct 2, 2023
1 parent ccd96b1 commit 7244574
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM redhat/ubi9-minimal
FROM docker.io/redhat/ubi9-minimal

ENV DJANGO_DB_PATH=/var/data/
ENV DJANGO_DEBUG=False
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.scan-target
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM redhat/ubi9-init
FROM docker.io/redhat/ubi9-init

RUN dnf -y install openssh-server openssl sudo; \
dnf clean all
Expand All @@ -16,4 +16,4 @@ RUN sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/s
RUN dnf -y install rct; \
dnf clean all

EXPOSE ${SSH_PORT}
EXPOSE ${SSH_PORT}
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ DIRS = test bin locale src
PYDIRS = quipucords
PIP_COMPILE_ARGS = --no-upgrade
BINDIR = bin
PARALLEL_NUM ?= $(shell python -c 'import multiprocessing as m;print(int(max(m.cpu_count()/2, 2)))')
PARALLEL_NUM ?= $(shell $(PYTHON) -c 'import multiprocessing as m;print(int(max(m.cpu_count()/2, 2)))')
TEST_OPTS := -n $(PARALLEL_NUM) -ra -m 'not slow' --timeout=15

QUIPUCORDS_CONTAINER_TAG ?= quipucords
QUIPUCORDS_UI_PATH ?= ../quipucords-ui
QUIPUCORDS_UI_RELEASE ?= latest

ifndef DOCKER_HOST
PODMAN_SOCKET := $(shell podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}' 2> /dev/null || podman info --format '{{.Host.RemoteSocket.Path}}' 2> /dev/null || echo -n "")

ifneq ($(PODMAN_SOCKET),)
ifneq ($(wildcard $(PODMAN_SOCKET)),)
export DOCKER_HOST := unix://$(PODMAN_SOCKET)
endif
endif
endif

help:
@echo "Please use \`make <target>' where <target> is one of:"
@echo " help to show this message"
Expand Down
2 changes: 1 addition & 1 deletion quipucords/tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def log_directory(tmp_path_factory):
"POSTGRES_PASSWORD": constants.POSTGRES_PASSWORD,
"POSTGRES_DB": constants.POSTGRES_DB,
},
image="postgres:12",
image="docker.io/library/postgres:12",
restart_policy={"Name": "on-failure"},
scope="class",
timeout=constants.READINESS_TIMEOUT_SECONDS,
Expand Down

0 comments on commit 7244574

Please sign in to comment.