Skip to content

Commit

Permalink
Introduces container-wrapper.sh
Browse files Browse the repository at this point in the history
Changelog:
- container-wrapper.sh is a script for detecting and running podman or docker. It displays a useful message when none of them is installed.
- Adds the server/scripts folder for holding all those utility scripts
- Adds a name to the container (planner-agent-ui) through the Makefile's run-image target for easy removal after it is no longer used.

Signed-off-by: Jonathan Kilzi <[email protected]>
  • Loading branch information
jkilzi committed Aug 4, 2024
1 parent 7cfb019 commit 2ec6dce
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
10 changes: 7 additions & 3 deletions server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ build:
go build -o build/planner-agent-ui ./cmd

# Image
image:
podman build -t $(IMAGE_REGISTRY)/$(REGISTRY_NAMESPACE)/planner-agent-ui:$(IMAGE_TAG) .
build-image:
scripts/container-wrapper.sh build -t $(IMAGE_REGISTRY)/$(REGISTRY_NAMESPACE)/planner-agent-ui:$(IMAGE_TAG) .

# Run image
.ONESHELL:
run-image:
podman run -it -p 8443:8443 $(IMAGE_REGISTRY)/$(REGISTRY_NAMESPACE)/planner-agent-ui:$(IMAGE_TAG)
scripts/container-wrapper.sh run -it \
--name planner-agent-ui \
-p 8443:8443 \
$(IMAGE_REGISTRY)/$(REGISTRY_NAMESPACE)/planner-agent-ui:$(IMAGE_TAG)

# Run
run: build
Expand Down
20 changes: 20 additions & 0 deletions server/scripts/container-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Determine which container runtime to use
if command_exists podman; then
CONTAINER_RUNTIME="podman"
elif command_exists docker; then
CONTAINER_RUNTIME="docker"
else
echo "Neither Podman nor Docker is installed. Please install one of them to proceed."
exit 1
fi

# Print the selected container runtime
#echo "Using $CONTAINER_RUNTIME as the container runtime."

$CONTAINER_RUNTIME "$@"
File renamed without changes.

0 comments on commit 2ec6dce

Please sign in to comment.