Initial commit
This commit is contained in:
commit
2683eae6b3
36 files changed
+7369
No files matched your search
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
IMAGE="${IMAGE:-localhost/wiki-print:latest}"
|
||||
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
if ! podman info >/dev/null 2>&1; then
|
||||
echo "Podman is not ready. Starting the Podman machine…"
|
||||
podman machine start
|
||||
fi
|
||||
|
||||
echo "Building ${IMAGE}…"
|
||||
podman build --target production --tag "$IMAGE" .
|
||||
|
||||
echo "Built ${IMAGE}."
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
MANIFEST="$ROOT_DIR/podman/wiki-print.pod.yaml"
|
||||
|
||||
podman play kube --down "$MANIFEST" >/dev/null 2>&1 || true
|
||||
if podman pod exists wiki-print >/dev/null 2>&1; then
|
||||
podman pod rm -f wiki-print
|
||||
fi
|
||||
if podman secret exists wiki-print-config >/dev/null 2>&1; then
|
||||
podman secret rm wiki-print-config >/dev/null 2>&1 || true
|
||||
fi
|
||||
if podman secret exists wiki-print-api-key >/dev/null 2>&1; then
|
||||
podman secret rm wiki-print-api-key >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
echo "Pod wiki-print removed."
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
CONTAINER="$(podman ps --filter pod=wiki-print --format '{{.Names}}' | head -n 1)"
|
||||
if [ -z "$CONTAINER" ]; then
|
||||
echo "No running container found in pod wiki-print."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec podman logs -f "$CONTAINER"
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
TEST_IMAGE="${TEST_IMAGE:-localhost/wiki-print:test}"
|
||||
|
||||
if ! podman info >/dev/null 2>&1; then
|
||||
echo "Podman is not ready. Starting the Podman machine…"
|
||||
podman machine start
|
||||
fi
|
||||
|
||||
cd "$ROOT_DIR"
|
||||
podman build --target test --tag "$TEST_IMAGE" .
|
||||
podman run --rm "$TEST_IMAGE"
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
IMAGE="${IMAGE:-localhost/wiki-print:latest}"
|
||||
MANIFEST="$ROOT_DIR/podman/wiki-print.pod.yaml"
|
||||
SECRET_NAME="wiki-print-config"
|
||||
|
||||
if [ -z "${WIKI_URL:-}" ]; then
|
||||
echo "WIKI_URL is not set." >&2
|
||||
echo "Export the Wiki.js URL before starting the pod, for example:" >&2
|
||||
echo " export WIKI_URL='https://wiki.example.com'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${WIKI_API_KEY:-}" ]; then
|
||||
echo "WIKI_API_KEY is not set." >&2
|
||||
echo "Export the Wiki.js API key before starting the pod, for example:" >&2
|
||||
echo " export WIKI_API_KEY='your-wiki-js-api-key'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! podman info >/dev/null 2>&1; then
|
||||
echo "Podman is not ready. Starting the Podman machine…"
|
||||
podman machine start
|
||||
fi
|
||||
|
||||
if ! podman image exists "$IMAGE"; then
|
||||
"$ROOT_DIR/scripts/build.sh"
|
||||
fi
|
||||
|
||||
# Recreate the pod before replacing the secret: a running container still
|
||||
# references the old secret, and Podman refuses to remove a secret in use.
|
||||
if podman pod exists wiki-print >/dev/null 2>&1; then
|
||||
podman play kube --down "$MANIFEST" >/dev/null 2>&1 || podman pod rm -f wiki-print >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
if podman secret exists "$SECRET_NAME" >/dev/null 2>&1; then
|
||||
podman secret rm "$SECRET_NAME" >/dev/null
|
||||
fi
|
||||
# Remove the secret used by older versions of these scripts.
|
||||
if podman secret exists wiki-print-api-key >/dev/null 2>&1; then
|
||||
podman secret rm wiki-print-api-key >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
# podman play kube expects the secret content to be a JSON map of raw values
|
||||
# (base64-encoded) or a Kubernetes Secret object.
|
||||
printf '{"WIKI_URL":"%s","WIKI_API_KEY":"%s"}' \
|
||||
"$(printf %s "$WIKI_URL" | base64 | tr -d '\n')" \
|
||||
"$(printf %s "$WIKI_API_KEY" | base64 | tr -d '\n')" \
|
||||
| podman secret create "$SECRET_NAME" - >/dev/null
|
||||
|
||||
echo "Creating pod wiki-print…"
|
||||
podman play kube --replace "$MANIFEST"
|
||||
|
||||
echo -n "Waiting for the web UI"
|
||||
for _ in $(seq 1 60); do
|
||||
if curl -fsS http://127.0.0.1:8080/healthz >/dev/null 2>&1; then
|
||||
echo
|
||||
echo "wiki-print is ready at http://localhost:8080"
|
||||
exit 0
|
||||
fi
|
||||
echo -n "."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo
|
||||
echo "The pod was created, but the health check did not become ready in time."
|
||||
echo "Inspect it with: ./scripts/logs.sh"
|
||||
exit 1
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Real Wiki.js connection details live outside the repository in a
|
||||
# permission-protected file. Override the path with WIKI_PRINT_TEST_ENV.
|
||||
ENV_FILE="${WIKI_PRINT_TEST_ENV:-.env}"
|
||||
if [ -f "$ENV_FILE" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$ENV_FILE"
|
||||
fi
|
||||
|
||||
if [ -z "${WIKI_URL:-}" ] || [ -z "${WIKI_API_KEY:-}" ]; then
|
||||
echo "WIKI_URL and WIKI_API_KEY must be set (for example in $ENV_FILE)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export LOG_LEVEL="${LOG_LEVEL:-debug}"
|
||||
exec ./scripts/up.sh
|
||||
Reference in new issue
Block a user