soapbox/run.sh

32 lines
1.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Starter (eller erstatter) soapbox-containeren med innstillinger fra .env.
# Idempotent: kjør på nytt etter build.sh for å rulle ut nytt image.
set -euo pipefail
cd "$(dirname "$0")"
ENV_FILE="${ENV_FILE:-.env}"
if [[ ! -f "$ENV_FILE" ]]; then
echo "Fant ikke $ENV_FILE kopier .env.example til .env og juster." >&2
exit 1
fi
# Verdier som bare gjelder for podman-kjøringen (ikke appen)
PORT="$(grep -E '^SOAPBOX_PORT=' "$ENV_FILE" | cut -d= -f2- || true)"
VOLUME="$(grep -E '^SOAPBOX_VOLUME=' "$ENV_FILE" | cut -d= -f2- || true)"
MEMORY="$(grep -E '^SOAPBOX_MEMORY=' "$ENV_FILE" | cut -d= -f2- || true)"
PORT="${PORT:-8080}"
VOLUME="${VOLUME:-soapbox-data}"
MEMORY="${MEMORY:-512m}"
IMAGE="${1:-localhost/soapbox:latest}"
podman run -d --replace --name soapbox \
--restart unless-stopped \
--cap-drop=all --security-opt=no-new-privileges \
--memory "$MEMORY" \
-p "127.0.0.1:${PORT}:8080" \
-v "${VOLUME}:/data:Z" \
--env-file "$ENV_FILE" \
"$IMAGE"
echo "soapbox kjører på http://127.0.0.1:${PORT}/ (data i ${VOLUME})"
echo "Logger: podman logs -f soapbox"