Files
pocketkv/deploy.sh
T
Paul TalandClaude Opus 5.5 f8e851fdb9 Add Docker deployment with deploy.sh
- Dockerfile: static build on alpine, runs as non-root, data on /data
  volume, health check on /healthz
- deploy.sh: builds the image and (re)starts a detached container with
  restart policy, .env as env file and the pocketkv-data volume
- .env.example: PORT for the host port; go-run-only settings commented out
- README: Docker deployment, updates, backups and HTTPS via Caddy

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-22 22:30:29 +02:00

33 lines
983 B
Bash
Executable File

#!/usr/bin/env bash
# Build the pocketkv image and (re)start it as a background container.
# Data lives in the Docker volume "pocketkv-data", so it survives redeploys.
set -euo pipefail
cd "$(dirname "$0")"
NAME=pocketkv
VOLUME=pocketkv-data
if [[ ! -f .env ]]; then
echo "Missing .env: run 'cp .env.example .env' and set DASHBOARD_USER / DASHBOARD_PASSWORD." >&2
exit 1
fi
command -v docker >/dev/null || { echo "Docker is not installed: https://docs.docker.com/engine/install/" >&2; exit 1; }
# Host port (or ip:port) to publish on; read from .env, default 8080.
PORT=$(sed -n 's/^PORT=//p' .env | tail -n 1)
PORT=${PORT:-8080}
docker build -t "$NAME" .
docker rm -f "$NAME" >/dev/null 2>&1 || true
docker run -d \
--name "$NAME" \
--restart unless-stopped \
--env-file .env \
-e ADDR=:8080 \
-e DATA_FILE=/data/pocketkv.json \
-p "$PORT:8080" \
-v "$VOLUME:/data" \
"$NAME" >/dev/null
echo "pocketkv is running on port $PORT (logs: docker logs -f $NAME)"