From 60fe4798b7bc49793262d697c61c7b8512efef93 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Sat, 3 Feb 2024 13:20:53 -0500 Subject: [PATCH 1/5] build(deps): ensure that provisioning installs podman --- apt.txt | 1 + provision.sh | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 apt.txt create mode 100644 provision.sh diff --git a/apt.txt b/apt.txt new file mode 100644 index 0000000..5247d59 --- /dev/null +++ b/apt.txt @@ -0,0 +1 @@ +podman diff --git a/provision.sh b/provision.sh new file mode 100644 index 0000000..8e17c5c --- /dev/null +++ b/provision.sh @@ -0,0 +1,7 @@ +#/bin/bash + +# Ensure that dependencies are up to date. +sudo apt update && sudo apt upgrade -y --autoremove + +# Ensure that critical dependencies are installed. +sudo apt install $(cat apt.txt) -y From 2537fd43ffae322e8269006dbfad6935c8a24c51 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Sat, 3 Feb 2024 13:26:05 -0500 Subject: [PATCH 2/5] feat(scripts): replace docker calls with equivalent podman calls in services --- services/bastion/build.sh | 2 +- services/bastion/start.sh | 4 ++-- services/bastion/stop.sh | 2 +- services/bitwarden/build.sh | 4 ++-- services/bitwarden/start.sh | 6 +++--- services/bitwarden/stop.sh | 4 ++-- services/bookstack/build.sh | 4 ++-- services/bookstack/start.sh | 6 +++--- services/bookstack/stop.sh | 4 ++-- services/deluge/build.sh | 2 +- services/deluge/start.sh | 4 ++-- services/deluge/stop.sh | 2 +- services/plex/build.sh | 2 +- services/plex/start.sh | 4 ++-- services/plex/stop.sh | 2 +- 15 files changed, 26 insertions(+), 26 deletions(-) diff --git a/services/bastion/build.sh b/services/bastion/build.sh index 0123c23..c3135e1 100644 --- a/services/bastion/build.sh +++ b/services/bastion/build.sh @@ -2,4 +2,4 @@ source constants.sh -docker build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bastion-app . +podman build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bastion-app . diff --git a/services/bastion/start.sh b/services/bastion/start.sh index 2d8f247..597d978 100644 --- a/services/bastion/start.sh +++ b/services/bastion/start.sh @@ -2,9 +2,9 @@ source constants.sh -docker network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" +podman network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" -docker run \ +podman run \ --detach \ --network $NETWORK_NAME \ --name $APP_CONTAINER_NAME \ diff --git a/services/bastion/stop.sh b/services/bastion/stop.sh index 871ff06..78156cb 100644 --- a/services/bastion/stop.sh +++ b/services/bastion/stop.sh @@ -2,4 +2,4 @@ source constants.sh -docker rm -f $APP_CONTAINER_NAME +podman rm -f $APP_CONTAINER_NAME diff --git a/services/bitwarden/build.sh b/services/bitwarden/build.sh index de4d126..d3c3f02 100644 --- a/services/bitwarden/build.sh +++ b/services/bitwarden/build.sh @@ -2,5 +2,5 @@ source constants.sh -docker build -t $DB_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bitwarden-db . -docker build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bitwarden-app . +podman build -t $DB_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bitwarden-db . +podman build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bitwarden-app . diff --git a/services/bitwarden/start.sh b/services/bitwarden/start.sh index a904191..704d0f1 100644 --- a/services/bitwarden/start.sh +++ b/services/bitwarden/start.sh @@ -2,9 +2,9 @@ source constants.sh -docker network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" +podman network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" -docker run \ +podman run \ --detach \ --network $NETWORK_NAME \ --name $DB_CONTAINER_NAME \ @@ -12,7 +12,7 @@ docker run \ --mount type=bind,source=$APP_DATA_DIR/bitwarden/db,target=/var/lib/mysql \ $DB_IMAGE_NAME:$IMAGE_VERSION -docker run \ +podman run \ --detach \ --network $NETWORK_NAME \ --name $APP_CONTAINER_NAME \ diff --git a/services/bitwarden/stop.sh b/services/bitwarden/stop.sh index 62c5c50..ea7d565 100644 --- a/services/bitwarden/stop.sh +++ b/services/bitwarden/stop.sh @@ -2,5 +2,5 @@ source constants.sh -docker rm -f $APP_CONTAINER_NAME -docker rm -f $DB_CONTAINER_NAME +podman rm -f $APP_CONTAINER_NAME +podman rm -f $DB_CONTAINER_NAME diff --git a/services/bookstack/build.sh b/services/bookstack/build.sh index c53c7c9..cdce680 100644 --- a/services/bookstack/build.sh +++ b/services/bookstack/build.sh @@ -2,5 +2,5 @@ source constants.sh -docker build -t $DB_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bookstack-db . -docker build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bookstack-app . +podman build -t $DB_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bookstack-db . +podman build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bookstack-app . diff --git a/services/bookstack/start.sh b/services/bookstack/start.sh index 86ebdd7..ed64838 100644 --- a/services/bookstack/start.sh +++ b/services/bookstack/start.sh @@ -2,9 +2,9 @@ source constants.sh -docker network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" +podman network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" -docker run \ +podman run \ --detach \ --network $NETWORK_NAME \ --name $DB_CONTAINER_NAME \ @@ -12,7 +12,7 @@ docker run \ --mount type=bind,source=$APP_DATA_DIR/bookstack-db,target=/var/lib/mysql \ $DB_IMAGE_NAME:$IMAGE_VERSION -docker run \ +podman run \ --detach \ --network $NETWORK_NAME \ --name $APP_CONTAINER_NAME \ diff --git a/services/bookstack/stop.sh b/services/bookstack/stop.sh index 62c5c50..ea7d565 100644 --- a/services/bookstack/stop.sh +++ b/services/bookstack/stop.sh @@ -2,5 +2,5 @@ source constants.sh -docker rm -f $APP_CONTAINER_NAME -docker rm -f $DB_CONTAINER_NAME +podman rm -f $APP_CONTAINER_NAME +podman rm -f $DB_CONTAINER_NAME diff --git a/services/deluge/build.sh b/services/deluge/build.sh index 0560945..d8fa3af 100644 --- a/services/deluge/build.sh +++ b/services/deluge/build.sh @@ -2,4 +2,4 @@ source constants.sh -docker build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-deluge-app . +podman build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-deluge-app . diff --git a/services/deluge/start.sh b/services/deluge/start.sh index facfdea..eadcbd7 100644 --- a/services/deluge/start.sh +++ b/services/deluge/start.sh @@ -2,9 +2,9 @@ source constants.sh -docker network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" +podman network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" -docker run \ +podman run \ --detach \ --network $NETWORK_NAME \ --name $APP_CONTAINER_NAME \ diff --git a/services/deluge/stop.sh b/services/deluge/stop.sh index 871ff06..78156cb 100644 --- a/services/deluge/stop.sh +++ b/services/deluge/stop.sh @@ -2,4 +2,4 @@ source constants.sh -docker rm -f $APP_CONTAINER_NAME +podman rm -f $APP_CONTAINER_NAME diff --git a/services/plex/build.sh b/services/plex/build.sh index 5e39262..9dd46c7 100644 --- a/services/plex/build.sh +++ b/services/plex/build.sh @@ -2,4 +2,4 @@ source constants.sh -docker build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-plex-app . +podman build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-plex-app . diff --git a/services/plex/start.sh b/services/plex/start.sh index a623874..5929724 100644 --- a/services/plex/start.sh +++ b/services/plex/start.sh @@ -2,9 +2,9 @@ source constants.sh -docker network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" +podman network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" -docker run \ +podman run \ --detach \ --network $NETWORK_NAME \ --name $APP_CONTAINER_NAME \ diff --git a/services/plex/stop.sh b/services/plex/stop.sh index 871ff06..78156cb 100644 --- a/services/plex/stop.sh +++ b/services/plex/stop.sh @@ -2,4 +2,4 @@ source constants.sh -docker rm -f $APP_CONTAINER_NAME +podman rm -f $APP_CONTAINER_NAME From ca30887fc7ca1a93b86000e0811951589798247a Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Mon, 5 Feb 2024 00:23:09 -0500 Subject: [PATCH 3/5] feat(pod): link all services under a single pod --- pod.sh | 4 ++++ services/bitwarden/start.sh | 7 ++----- services/bookstack/start.sh | 10 ++++------ services/deluge/start.sh | 7 +------ services/plex/start.sh | 3 --- 5 files changed, 11 insertions(+), 20 deletions(-) create mode 100644 pod.sh diff --git a/pod.sh b/pod.sh new file mode 100644 index 0000000..17abf74 --- /dev/null +++ b/pod.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +podman pod exists services +test $? -eq 0 || podman pod create services diff --git a/services/bitwarden/start.sh b/services/bitwarden/start.sh index 704d0f1..02d5c04 100644 --- a/services/bitwarden/start.sh +++ b/services/bitwarden/start.sh @@ -2,11 +2,9 @@ source constants.sh -podman network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" - podman run \ --detach \ - --network $NETWORK_NAME \ + --pod services \ --name $DB_CONTAINER_NAME \ --env-file $ENV_FILE_DIR/bitwarden-db.env \ --mount type=bind,source=$APP_DATA_DIR/bitwarden/db,target=/var/lib/mysql \ @@ -14,10 +12,9 @@ podman run \ podman run \ --detach \ - --network $NETWORK_NAME \ + --pod services \ --name $APP_CONTAINER_NAME \ --env-file $ENV_FILE_DIR/bitwarden-web.env \ - --publish 8080:8080 \ --mount type=bind,source=$APP_DATA_DIR/bitwarden/config,target=/etc/bitwarden \ --mount type=bind,source=$APP_DATA_DIR/bitwarden/logs,target=/var/log/bitwarden \ $APP_IMAGE_NAME:$IMAGE_VERSION diff --git a/services/bookstack/start.sh b/services/bookstack/start.sh index ed64838..cca42fd 100644 --- a/services/bookstack/start.sh +++ b/services/bookstack/start.sh @@ -2,21 +2,19 @@ source constants.sh -podman network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" - podman run \ --detach \ - --network $NETWORK_NAME \ + --pod services \ --name $DB_CONTAINER_NAME \ --env-file $ENV_FILE_DIR/bookstack-db.env \ --mount type=bind,source=$APP_DATA_DIR/bookstack-db,target=/var/lib/mysql \ - $DB_IMAGE_NAME:$IMAGE_VERSION + mariadb:10.6 \ + --port 3307 podman run \ --detach \ - --network $NETWORK_NAME \ + --pod services \ --name $APP_CONTAINER_NAME \ --env-file $ENV_FILE_DIR/bookstack-app.env \ - --publish 6875:80 \ --mount type=bind,source=$APP_DATA_DIR/bookstack-app,target=/config \ $APP_IMAGE_NAME:$IMAGE_VERSION diff --git a/services/deluge/start.sh b/services/deluge/start.sh index eadcbd7..92408e2 100644 --- a/services/deluge/start.sh +++ b/services/deluge/start.sh @@ -2,16 +2,11 @@ source constants.sh -podman network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" - podman run \ --detach \ - --network $NETWORK_NAME \ + --pod services \ --name $APP_CONTAINER_NAME \ --env-file $ENV_FILE_DIR/deluge.env \ - --publish 8112:8112 \ - --publish 6881:6881/udp \ - --publish 6881:6881/tcp \ --mount type=bind,source=$APP_DATA_DIR/deluge/config,target=/config \ --mount type=bind,source=$APP_DATA_DIR/deluge/downloads,target=/downloads \ --mount type=bind,source=$STORAGE_DIR,target=/complete \ diff --git a/services/plex/start.sh b/services/plex/start.sh index 5929724..ba8a74f 100644 --- a/services/plex/start.sh +++ b/services/plex/start.sh @@ -2,11 +2,8 @@ source constants.sh -podman network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" - podman run \ --detach \ - --network $NETWORK_NAME \ --name $APP_CONTAINER_NAME \ --env-file $ENV_FILE_DIR/plex.env \ --publish 32401:32400 \ From a4f9f3e2ab8682cfb6c7593b7de31a242088a78e Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Thu, 8 Feb 2024 23:43:24 -0500 Subject: [PATCH 4/5] refactor(scripts): clean up references to networks --- Taskfile.yml | 4 ++++ services/bastion/constants.sh | 1 - services/bastion/start.sh | 4 +--- services/bitwarden/constants.sh | 1 - services/bookstack/constants.sh | 1 - services/deluge/constants.sh | 1 - services/deluge/start.sh | 2 ++ 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 678a709..bbdf391 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -17,6 +17,9 @@ vars: sh: git describe --tags --exact-match $(git rev-parse HEAD) 2> /dev/null || echo "dev-$(git rev-parse HEAD)" tasks: + ensure-pod: + desc: "Creates the pod if it doesn't already exist." + cmd: . ./pod.sh build: desc: "Builds images for one or more services. Include service names as a space-separated list." cmds: @@ -28,6 +31,7 @@ tasks: prefix: "build: {{ .CLI_ARGS }}" dir: services start: + deps: [ensure-pod] desc: "Starts one or more services. Include service names as a space-separated list." cmds: - for: { var: CLI_ARGS } diff --git a/services/bastion/constants.sh b/services/bastion/constants.sh index 6a11f1c..abae0df 100644 --- a/services/bastion/constants.sh +++ b/services/bastion/constants.sh @@ -3,4 +3,3 @@ export APP_NAME="bastion" export APP_CONTAINER_NAME=$APP_NAME-app export APP_IMAGE_NAME=$CONTAINER_NAME_PREFIX-$APP_CONTAINER_NAME -export NETWORK_NAME=$APP_NAME-local diff --git a/services/bastion/start.sh b/services/bastion/start.sh index 597d978..cb034e5 100644 --- a/services/bastion/start.sh +++ b/services/bastion/start.sh @@ -2,11 +2,9 @@ source constants.sh -podman network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" - podman run \ --detach \ - --network $NETWORK_NAME \ + --pod services \ --name $APP_CONTAINER_NAME \ --env-file $ENV_FILE_DIR/bastion.env \ $APP_IMAGE_NAME:$IMAGE_VERSION diff --git a/services/bitwarden/constants.sh b/services/bitwarden/constants.sh index 2df6d9c..ba3d16e 100644 --- a/services/bitwarden/constants.sh +++ b/services/bitwarden/constants.sh @@ -5,4 +5,3 @@ export APP_CONTAINER_NAME=$APP_NAME-app export APP_IMAGE_NAME=$CONTAINER_NAME_PREFIX-$APP_CONTAINER_NAME export DB_CONTAINER_NAME=$APP_NAME-db export DB_IMAGE_NAME=$CONTAINER_NAME_PREFIX-$DB_CONTAINER_NAME -export NETWORK_NAME=$APP_NAME-local diff --git a/services/bookstack/constants.sh b/services/bookstack/constants.sh index 8c68636..01376f9 100644 --- a/services/bookstack/constants.sh +++ b/services/bookstack/constants.sh @@ -5,4 +5,3 @@ export APP_CONTAINER_NAME=$APP_NAME-app export APP_IMAGE_NAME=$CONTAINER_NAME_PREFIX-$APP_CONTAINER_NAME export DB_CONTAINER_NAME=$APP_NAME-db export DB_IMAGE_NAME=$CONTAINER_NAME_PREFIX-$DB_CONTAINER_NAME -export NETWORK_NAME=$APP_NAME-local diff --git a/services/deluge/constants.sh b/services/deluge/constants.sh index e68981f..834c9b0 100644 --- a/services/deluge/constants.sh +++ b/services/deluge/constants.sh @@ -3,4 +3,3 @@ export APP_NAME="deluge" export APP_CONTAINER_NAME=$APP_NAME-app export APP_IMAGE_NAME=$CONTAINER_NAME_PREFIX-$APP_CONTAINER_NAME -export NETWORK_NAME=$APP_NAME-local diff --git a/services/deluge/start.sh b/services/deluge/start.sh index 92408e2..6b834a6 100644 --- a/services/deluge/start.sh +++ b/services/deluge/start.sh @@ -5,6 +5,8 @@ source constants.sh podman run \ --detach \ --pod services \ + -e PGUID=1000 \ + -e PGID=1000 \ --name $APP_CONTAINER_NAME \ --env-file $ENV_FILE_DIR/deluge.env \ --mount type=bind,source=$APP_DATA_DIR/deluge/config,target=/config \ From 15f2c6c5347a6cf6bfb9b953e384fc5507fce12d Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Fri, 9 Feb 2024 00:10:24 -0500 Subject: [PATCH 5/5] fix: ensure that pod can be created from scratch --- pod.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pod.sh b/pod.sh index 17abf74..d8f0330 100644 --- a/pod.sh +++ b/pod.sh @@ -1,4 +1,4 @@ #!/bin/bash -podman pod exists services -test $? -eq 0 || podman pod create services +podman pod exists services || true +test $? -eq 0 || podman pod create -p 8080:8080 -p 6881:6881/udp -p 6881:6881 -p 8112:8112 services