25 lines
661 B
Bash
25 lines
661 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
PORTAINER_URL="https://portainer.local:9443"
|
|
API_KEY="HIER_DEIN_API_KEY"
|
|
ENDPOINT_ID="1"
|
|
STACK_NAME="robot-renderer"
|
|
COMPOSE_FILE="$(dirname "$0")/docker-compose.yml"
|
|
|
|
PAYLOAD="$(python - <<'PY'
|
|
import json, pathlib, os
|
|
compose_file = pathlib.Path(os.environ["COMPOSE_FILE"])
|
|
compose = compose_file.read_text(encoding="utf-8")
|
|
print(json.dumps({
|
|
"name": os.environ["STACK_NAME"],
|
|
"StackFileContent": compose
|
|
}))
|
|
PY
|
|
)"
|
|
|
|
curl -k -sS -X POST \
|
|
"$PORTAINER_URL/api/stacks/create/standalone/string?endpointId=$ENDPOINT_ID" \
|
|
-H "X-API-Key: $API_KEY" \
|
|
-H "Content-Type: application/json" \
|
|
--data-raw "$PAYLOAD" |