From 1f59a06fb1d493650f34e81c5313c332ededbe86 Mon Sep 17 00:00:00 2001 From: Matt Colman <33348891+mtcolman@users.noreply.github.com> Date: Wed, 13 Nov 2024 09:36:42 +0000 Subject: [PATCH] healthcheck bug fix and add podman compatibility (#68) * healthcheck bug fix and add podman compatibility Signed-off-by: Matt Colman * fixed typo Signed-off-by: Matt Colman --------- Signed-off-by: Matt Colman --- Makefile | 26 ++++++++++++++------------ README.md | 9 +++++++++ docker-compose.yaml | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index fc0fd6d89..2673add2c 100644 --- a/Makefile +++ b/Makefile @@ -1,33 +1,35 @@ # extract cbomkit version tag from pom.xml VERSION := $(shell curl -s https://api.github.com/repos/IBM/cbomkit/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') +# set engine to use for build and compose, default to docker +ENGINE ?= docker # build the backend build-backend: dev ./mvnw clean package -# build the docker image for the backend +# build the container image for the backend build-backend-image: build-backend - docker build \ + $(ENGINE) build \ -t cbomkit:${VERSION} \ -f src/main/docker/Dockerfile.jvm \ . \ --load -# build the docker image for the frontend +# build the container image for the frontend build-frontend-image: - docker build \ + $(ENGINE) build \ -t cbomkit-frontend:${VERSION} \ -f frontend/docker/Dockerfile \ ./frontend \ --load -# run the dev setup using docker compose +# run the dev setup using docker/podman compose dev: - env CBOMKIT_VERSION=${VERSION} CBOMKIT_VIEWER=false POSTGRESQL_AUTH_USERNAME=cbomkit POSTGRESQL_AUTH_PASSWORD=cbomkit docker-compose --profile dev up -d + env CBOMKIT_VERSION=${VERSION} CBOMKIT_VIEWER=false POSTGRESQL_AUTH_USERNAME=cbomkit POSTGRESQL_AUTH_PASSWORD=cbomkit $(ENGINE)-compose --profile dev up -d dev-backend: - env CBOMKIT_VERSION=${VERSION} CBOMKIT_VIEWER=false POSTGRESQL_AUTH_USERNAME=cbomkit POSTGRESQL_AUTH_PASSWORD=cbomkit docker-compose --profile dev-backend up + env CBOMKIT_VERSION=${VERSION} CBOMKIT_VIEWER=false POSTGRESQL_AUTH_USERNAME=cbomkit POSTGRESQL_AUTH_PASSWORD=cbomkit $(ENGINE)-compose --profile dev-backend up dev-frontend: - env CBOMKIT_VERSION=${VERSION} CBOMKIT_VIEWER=false POSTGRESQL_AUTH_USERNAME=cbomkit POSTGRESQL_AUTH_PASSWORD=cbomkit docker-compose --profile dev-frontend up -# run the prod setup using docker compose + env CBOMKIT_VERSION=${VERSION} CBOMKIT_VIEWER=false POSTGRESQL_AUTH_USERNAME=cbomkit POSTGRESQL_AUTH_PASSWORD=cbomkit $(ENGINE)-compose --profile dev-frontend up +# run the prod setup using $(ENGINE) compose production: - env CBOMKIT_VERSION=${VERSION} CBOMKIT_VIEWER=false POSTGRESQL_AUTH_USERNAME=cbomkit POSTGRESQL_AUTH_PASSWORD=cbomkit docker-compose --profile prod up + env CBOMKIT_VERSION=${VERSION} CBOMKIT_VIEWER=false POSTGRESQL_AUTH_USERNAME=cbomkit POSTGRESQL_AUTH_PASSWORD=cbomkit $(ENGINE)-compose --profile prod up coeus: - env CBOMKIT_VERSION=${VERSION} CBOMKIT_VIEWER=true docker-compose --profile viewer up + env CBOMKIT_VERSION=${VERSION} CBOMKIT_VIEWER=true $(ENGINE)-compose --profile viewer up ext-compliance: - env CBOMKIT_VERSION=${VERSION} CBOMKIT_VIEWER=false POSTGRESQL_AUTH_USERNAME=cbomkit POSTGRESQL_AUTH_PASSWORD=cbomkit docker-compose --profile ext-compliance up \ No newline at end of file + env CBOMKIT_VERSION=${VERSION} CBOMKIT_VIEWER=false POSTGRESQL_AUTH_USERNAME=cbomkit POSTGRESQL_AUTH_PASSWORD=cbomkit $(ENGINE)-compose --profile ext-compliance up \ No newline at end of file diff --git a/README.md b/README.md index 6bac992c2..3c3440e24 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,15 @@ git clone https://github.com/IBM/cbomkit # run the make command to start the docker compose make production ``` + +Alternatively, if you wish to use podman instead of docker, run the following: +``` +# run the make command to start the docker compose using podman +make production ENGINE=podman +``` + +(This requires podman-compose to have been installed via `pip3 install podman-compose`). + Next steps: - Enter a git url like [https://github.com/keycloak/keycloak](https://github.com/keycloak/keycloak) to generate a CBOM - View your generated CBOM by selecting your previously scanned CBOM diff --git a/docker-compose.yaml b/docker-compose.yaml index 84eb4fb51..4033935dc 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -64,7 +64,7 @@ services: ports: - "5432:5432" healthcheck: - test: [ "CMD", "pg_isready -U postgres" ] + test: [ "CMD", "pg_isready -U ${POSTGRESQL_AUTH_USERNAME} -d postgres" ] interval: 10s timeout: 5s retries: 5