37 lines
1.2 KiB
Bash
Executable File
37 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# sample-secrets.sh
|
|
# This script demonstrates how to provision the necessary Swarm secrets
|
|
# for the billing system.
|
|
|
|
# 1. Stripe Secret Key (from Stripe Dashboard -> Developers -> API keys)
|
|
# Usage: echo "sk_test_..." | ./sample-secrets.sh
|
|
if [ -t 0 ]; then
|
|
echo "Error: Please pipe the Stripe Secret Key into this script."
|
|
echo "Example: echo \"sk_test_...\" | $0"
|
|
exit 1
|
|
fi
|
|
|
|
STRIPE_SK=$(cat -)
|
|
|
|
echo "Creating 'control_stripe_secret_key' secret..."
|
|
echo "$STRIPE_SK" | docker secret create control_stripe_secret_key -
|
|
|
|
# 2. Stripe Webhook Secret (from Stripe Dashboard -> Developers -> Webhooks -> [Endpoint])
|
|
# Note: You get this after configuring the endpoint in the dashboard.
|
|
echo "NOTE: Remember to also create 'control_stripe_webhook_secret' once you have it."
|
|
# echo "whsec_..." | docker secret create control_stripe_webhook_secret -
|
|
|
|
echo "Done. Update your stack file to reference these secrets:"
|
|
echo "
|
|
services:
|
|
control-api:
|
|
secrets:
|
|
- control_stripe_secret_key
|
|
- control_stripe_webhook_secret
|
|
environment:
|
|
- CONTROL_STRIPE_SECRET_KEY_FILE=/run/secrets/control_stripe_secret_key
|
|
- CONTROL_STRIPE_WEBHOOK_SECRET_FILE=/run/secrets/control_stripe_webhook_secret
|
|
"
|