Skip to content

Commit

Permalink
Feature: Updated podman image paths to be dynamic (#132)
Browse files Browse the repository at this point in the history
* Updated image paths to be dynamic

* Version bump [0.6.3]

* Added Z to postgres-initdb

* Updated naming to be consistent

* Removed reload-cert as an option
  • Loading branch information
Michael-Burke authored Apr 30, 2024
1 parent c1cca39 commit 5a54f0f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.6.2
current_version = 0.6.3

commit = True
tag = True
Expand Down
29 changes: 25 additions & 4 deletions src/_podman.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,21 @@ function podman_setup() {
function plextrac_install_podman() {
var=$(declare -p "$1")
eval "declare -A serviceValues="${var#*=}
CB_IMAGE="${CB_IMAGE:-docker.io/plextrac/plextracdb:7.2.0}"
PG_IMAGE="${PG_IMAGE:-docker.io/postgres:14-alpine}"
REDIS_IMAGE="${REDIS_IMAGE:-docker.io/redis:6.2-alpine}"
API_IMAGE="${API_IMAGE:-docker.io/plextrac/plextracapi:${UPGRADE_STRATEGY:-stable}}"
NGINX_IMAGE="${NGINX_IMAGE:-docker.io/plextrac/plextracnginx:${UPGRADE_STRATEGY:-stable}}"

serviceValues[cb-image]="${CB_IMAGE}"
serviceValues[pg-image]="${PG_IMAGE}"
serviceValues[redis-image]="${REDIS_IMAGE}"
serviceValues[api-image]="${API_IMAGE}"
serviceValues[plextracnginx-image]="${NGINX_IMAGE}"

serviceValues[env-file]="--env-file ${PLEXTRAC_HOME:-}/.env"
serviceValues[redis-entrypoint]=$(printf '%s' "--entrypoint=" "[" "\"redis-server\"" "," "\"--requirepass\"" "," "\"${REDIS_PASSWORD}\"" "]")
serviceValues[cb-healthcheck]='--health-cmd=["wget","--user='$CB_ADMIN_USER'","--password='$CB_ADMIN_PASS'","-qO-","http://plextracdb:8091/pools/default/buckets/reportMe"]'
serviceValues[api-image]="docker.io/plextrac/plextracapi:${UPGRADE_STRATEGY:-stable}"
serviceValues[plextracnginx-image]="docker.io/plextrac/plextracnginx:${UPGRADE_STRATEGY:-stable}"
if [ "$LETS_ENCRYPT_EMAIL" != '' ] && [ "$USE_CUSTOM_CERT" == 'false' ]; then
serviceValues[plextracnginx-ports]="-p 0.0.0.0:443:443 -p 0.0.0.0:80:80"
else
Expand Down Expand Up @@ -135,8 +146,18 @@ function plextrac_start_podman() {
eval "declare -A serviceValues="${var#*=}
serviceValues[redis-entrypoint]=$(printf '%s' "--entrypoint=" "[" "\"redis-server\"" "," "\"--requirepass\"" "," "\"${REDIS_PASSWORD}\"" "]")
serviceValues[cb-healthcheck]='--health-cmd=["wget","--user='$CB_ADMIN_USER'","--password='$CB_ADMIN_PASS'","-qO-","http://plextracdb:8091/pools/default/buckets/reportMe"]'
serviceValues[api-image]="docker.io/plextrac/plextracapi:${UPGRADE_STRATEGY:-stable}"
serviceValues[plextracnginx-image]="docker.io/plextrac/plextracnginx:${UPGRADE_STRATEGY:-stable}"
CB_IMAGE="${CB_IMAGE:-docker.io/plextrac/plextracdb:7.2.0}"
PG_IMAGE="${PG_IMAGE:-docker.io/postgres:14-alpine}"
REDIS_IMAGE="${REDIS_IMAGE:-docker.io/redis:6.2-alpine}"
API_IMAGE="${API_IMAGE:-docker.io/plextrac/plextracapi:${UPGRADE_STRATEGY:-stable}}"
NGINX_IMAGE="${NGINX_IMAGE:-docker.io/plextrac/plextracnginx:${UPGRADE_STRATEGY:-stable}}"

serviceValues[cb-image]="${CB_IMAGE}"
serviceValues[pg-image]="${PG_IMAGE}"
serviceValues[redis-image]="${REDIS_IMAGE}"
serviceValues[api-image]="${API_IMAGE}"
serviceValues[plextracnginx-image]="${NGINX_IMAGE}"
serviceValues[env-file]="--env-file ${PLEXTRAC_HOME:-}/.env"
if [ "$LETS_ENCRYPT_EMAIL" != '' ] && [ "$USE_CUSTOM_CERT" == 'false' ]; then
serviceValues[plextracnginx-ports]="-p 0.0.0.0:443:443 -p 0.0.0.0:80:80"
else
Expand Down
29 changes: 17 additions & 12 deletions src/_reload_cert.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Build functionality for certificate renewal / injection into NGINX

function mod_reload-cert() {
var=$(declare -p "$1")
eval "declare -A serviceValues="${var#*=}
if [ "$LETS_ENCRYPT_EMAIL" != '' ] && [ "$USE_CUSTOM_CERT" == 'false' ]; then
serviceValues[plextracnginx-ports]="-p 0.0.0.0:443:443 -p 0.0.0.0:80:80"
else
serviceValues[plextracnginx-ports]="-p 0.0.0.0:443:443"
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
die "Not yet implemented in Podman"
fi
# var=$(declare -p "$1")
# eval "declare -A serviceValues="${var#*=}
# if [ "$LETS_ENCRYPT_EMAIL" != '' ] && [ "$USE_CUSTOM_CERT" == 'false' ]; then
# serviceValues[plextracnginx-ports]="-p 0.0.0.0:443:443 -p 0.0.0.0:80:80"
# else
# serviceValues[plextracnginx-ports]="-p 0.0.0.0:443:443"
# fi

title "PlexTrac SSL Certificate Renewal"
# Check if using LETS_ENCRYPT
Expand All @@ -21,9 +24,10 @@ function mod_reload-cert() {
if get_user_approval; then
info "Recreating plextrac-plextracnginx-1"
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
podman rm -f plextracnginx; podman volume rm letsencrypt
podman run ${serviceValues[env-file]} --restart=always \
${serviceValues[plextracnginx-volumes]} --name=plextracnginx --network=plextrac ${serviceValues[plextracnginx-ports]} -d ${serviceValues[plextracnginx-image]} 1>/dev/null
die "Not yet implemented in Podman"
# podman rm -f plextracnginx; podman volume rm letsencrypt
# podman run ${serviceValues[env-file]} --restart=always \
# ${serviceValues[plextracnginx-volumes]} --name=plextracnginx --network=plextrac ${serviceValues[plextracnginx-ports]} -d ${serviceValues[plextracnginx-image]} 1>/dev/null
else
compose_client up -d --force-recreate plextracnginx
fi
Expand All @@ -38,9 +42,10 @@ function mod_reload-cert() {
if get_user_approval; then
info "Reloading certificates..."
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
podman rm -f plextracnginx; podman volume rm letsencrypt
podman run ${serviceValues[env-file]} --restart=always \
${serviceValues[plextracnginx-volumes]} --name=plextracnginx --network=plextrac ${serviceValues[plextracnginx-ports]} -d ${serviceValues[plextracnginx-image]} 1>/dev/null
die "Not yet implemented in Podman"
# podman rm -f plextracnginx; podman volume rm letsencrypt
# podman run ${serviceValues[env-file]} --restart=always \
# ${serviceValues[plextracnginx-volumes]} --name=plextracnginx --network=plextrac ${serviceValues[plextracnginx-ports]} -d ${serviceValues[plextracnginx-image]} 1>/dev/null
else
compose_client up -d --force-recreate plextracnginx
fi
Expand Down
1 change: 0 additions & 1 deletion src/_setup_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ function install_podman() {
exit 1
;;
esac
touch /etc/containers/nodocker
log "Done."
else
info "podman already installed, version: $(podman --version | grep -o -E '.\..\..')"
Expand Down
9 changes: 3 additions & 6 deletions src/plextrac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -Eeuo pipefail

VERSION=0.6.2
VERSION=0.6.3


## Podman Global Declaration Variable
Expand All @@ -13,23 +13,19 @@ databaseNames=("plextracdb" "postgres")
serviceNames=("plextracdb" "postgres" "redis" "plextracapi" "notification-engine" "notification-sender" "contextual-scoring-service" "migrations" "plextracnginx")
#Defaults
svcValues[network]="--network=plextrac"
svcValues[env-file]="--env-file /opt/plextrac/.env"
#Couchbase
svcValues[cb-volumes]="-v dbdata:/opt/couchbase/var:Z,U -v couchbase-backups:/backups:Z,U"
svcValues[cb-ports]="-p 127.0.0.1:8091-8094:8091-8094"
svcValues[cb-image]="docker.io/plextrac/plextracdb:7.2.0"
#Postgres
svcValues[pg-volumes]="-v postgres-initdb:/docker-entrypoint-initdb.d -v postgres-data:/var/lib/postgresql/data -v postgres-backups:/backups:Z"
svcValues[pg-volumes]="-v postgres-initdb:/docker-entrypoint-initdb.d:Z -v postgres-data:/var/lib/postgresql/data -v postgres-backups:/backups:Z"
svcValues[pg-ports]="-p 127.0.0.1::5432"
svcValues[pg-healthcheck]='--health-cmd=["pg_isready","-U","internalonly"]'
svcValues[pg-image]="docker.io/postgres:14-alpine"
svcValues[pg-env-vars]="-e 'POSTGRES_HOST_AUTH_METHOD=scram-sha-256' -e 'PG_MIGRATE_PATH=/usr/src/plextrac-api' -e 'PGDATA=/var/lib/postgresql/data/pgdata'"
#API
svcValues[api-volumes]="-v uploads:/usr/src/plextrac-api/uploads:Z,U -v localesOverride:/usr/src/plextrac-api/localesOverride:rw"
svcValues[api-healthcheck]='--health-cmd=["wget","-q","-O-","http://127.0.0.1:4350/api/v2/health/live"]'
#Redis
svcValues[redis-volumes]="-v redis:/etc/redis:rw"
svcValues[redis-image]="docker.io/redis:6.2-alpine"
svcValues[redis-healthcheck]='--health-cmd=["redis-cli","--raw","incr","ping"]'
#Notification engine/sender
svcValues[notification-engine-entrypoint]='--entrypoint ["npm","run","start:notification-engine"]'
Expand All @@ -45,6 +41,7 @@ svcValues[migrations-volumes]="--volumes-from=plextracapi"
svcValues[plextracnginx-volumes]="-v letsencrypt:/etc/letsencrypt:rw -v nginx_ssl_certs:/etc/ssl/:Z,U -v nginx_logos:/usr/share/nginx/html/dist/img/:Z,U"
svcValues[plextracnginx-healthcheck]='--health-cmd=["echo","GET","/","|","openssl","s_client","-quiet","-connect","127.0.0.1:443"]'


trap 'cleanup $?' SIGINT ERR EXIT

function backtrace() {
Expand Down

0 comments on commit 5a54f0f

Please sign in to comment.