Containerized bootstrap script that automates the complete initial setup of a Tyk deployment using only Tyk APIs. Creates organization, admin user, test API, credentials, Developer Portal admin, and Dashboard provider connection.
Automates the complete initial setup of a Tyk deployment:
Dashboard Setup:
- ✅ Creates organization ("Demo Organization")
- ✅ Creates admin user with Dashboard access
- ✅ Sets admin password and API credentials
- ✅ Generates Dashboard API key for management
API Configuration:
- ✅ Creates test API using OAS 3.0 format (httpbingo proxy)
- ✅ Creates API policy with rate limits and quotas
- ✅ Generates API key for testing (with alias "test-api-key-123")
Developer Portal Setup:
- ✅ Bootstraps Developer Portal with admin user
- ✅ Configures Dashboard provider connection
- ✅ Saves all credentials to file
- External
tyknetwork must exist - Tyk Dashboard must be running at
http://tyk-dashboard:3000 - Tyk Gateway must be running at
http://tyk-gateway:8080 - (Optional) Tyk Portal running at
http://tyk-portal:3001 - Valid
TYK_LICENSE_KEYin.envfile
1. Set License Key
Create or edit .env file:
TYK_LICENSE_KEY=your-license-key-here2. Run Bootstrap
# Using the tools profile (recommended)
docker-compose --profile tools run --rm tyk-bootstrap
# Alternative: Direct docker compose run
docker compose run --rm tyk-bootstrap3. View Credentials
cat bootstrap-output/bootstrap-credentials.txtRun the script directly without Docker:
# Set environment variables
export TYK_LICENSE_KEY="your-license-key"
export DASHBOARD_URL="http://localhost:3000"
export GATEWAY_URL="http://localhost:8080"
export PORTAL_URL="http://localhost:3001"
export ADMIN_SECRET="admin-secret"
# Run script
bash bootstrap.sh| Variable | Default | Required | Description |
|---|---|---|---|
TYK_LICENSE_KEY |
- | ✅ | Tyk Dashboard license key |
DASHBOARD_URL |
http://tyk-dashboard:3000 |
✅ | Dashboard URL |
GATEWAY_URL |
http://tyk-gateway:8080 |
✅ | Gateway URL |
PORTAL_URL |
http://tyk-portal:3001 |
Developer Portal URL (optional) | |
ADMIN_SECRET |
admin-secret |
✅ | Dashboard admin API secret |
Note: Portal bootstrapping is optional. If Portal is not running, the script will skip portal configuration and continue.
Creates bootstrap-output/bootstrap-credentials.txt with:
- Dashboard login credentials
- Portal admin credentials
- API testing credentials
- Dashboard API key and Org ID
Bootstrap is idempotent - safe to run multiple times:
- ✅ Checks if organization exists → uses existing
- ✅ Checks if admin user exists → uses existing
- ✅ Checks if test API exists → uses existing
- ✅ Checks if policy exists → uses existing
- ✅ Checks if API key exists → uses existing
- ✅ Creates marker file (
.bootstrap_completed) to track completion
Re-run with existing setup:
# Loads existing credentials from file
docker-compose --profile tools run --rm tyk-bootstrapForce fresh bootstrap (only if you want to skip checks):
# Remove marker and credentials
rm -rf bootstrap-output/
# Run bootstrap again
docker-compose --profile tools run --rm tyk-bootstrap- Name: "Demo Organization"
- CNAME: Enabled
- Event Options: Redis hashed key events enabled
- Email:
admin@example.com - Password:
topsecret123 - Permissions: Full admin (
IsAdmin: "admin") - Access Key: Generated for Dashboard API access
- Name: "Httpbin Test API (OAS)"
- Format: OpenAPI 3.0.3 specification
- Listen Path:
/httpbin/(strip enabled) - Target URL:
https://httpbingo.org/ - Authentication: Auth token required (API key in
Authorizationheader) - Endpoints:
GET /httpbin/get- HTTP GET testPOST /httpbin/post- HTTP POST testGET /httpbin/anything/{path}- Wildcard endpoint
- Traffic Logs: Enabled
- Name: "Test API Policy"
- Rate Limit: 1000 requests per 60 seconds
- Quota: 1000 requests (allowance)
- Applies To: Httpbin Test API
- Alias:
test-api-key-123 - Valid For: Httpbin Test API
- Rate Limit: 1000 requests per 60 seconds
- Quota: Unlimited (-1)
- Format: Bearer token (use in
Authorizationheader)
- Admin Email:
portal-admin@example.com - Admin Password:
portalpass123 - API Token: Generated for Portal API access
- Provider: Tyk Dashboard connection configured
Remove bootstrap data:
rm -rf bootstrap-output/Full reset (Docker Compose):
# Stop all services and remove volumes
docker-compose down -v
# Remove bootstrap data
rm -rf bootstrap-output/
# Start services
docker-compose up -d
# Re-run bootstrap
docker-compose --profile tools run --rm tyk-bootstrapEdit bootstrap.sh to customize:
Lines 100-109: Admin user credentials
"email_address": "admin@example.com"
"new_password": "topsecret123"Lines 253-310: Test API configuration (OAS spec)
# Change target URL, endpoints, authentication
"url": "https://httpbingo.org/"Lines 358-380: Policy settings
"rate": 1000, # requests
"per": 60, # seconds
"allowance": 1000 # quotaLines 470-475: Portal admin credentials
"username": "portal-admin@example.com"
"password": "portalpass123"Bootstrap hangs waiting for Dashboard:
# Check Dashboard is running
docker-compose ps tyk-dashboard
# Check Dashboard logs
docker-compose logs tyk-dashboard
# Test Dashboard health endpoint
curl http://localhost:3000/hello
# Increase wait time in bootstrap.sh (line 87)
local max_attempts=30 # Change to 60"TYK_LICENSE_KEY not set" error:
# Check .env file exists
cat .env
# Verify license key is set
grep TYK_LICENSE_KEY .env
"Organization already exists" but credentials missing:
# List organizations
curl http://localhost:3000/admin/organisations/ \
-H "admin-auth: admin-secret"
# Remove marker to re-extract credentials
rm bootstrap-output/.bootstrap_completed
# Re-run bootstrap
docker-compose --profile tools run --rm tyk-bootstrapCredentials file not created:
# Check volume mount
docker-compose run --rm tyk-bootstrap ls -la /bootstrap-output
# Check local directory
ls -la bootstrap-output/
# Check permissions
chmod -R 755 bootstrap-output/Portal bootstrapping fails:
# Check Portal is running
curl http://localhost:3001/hello
# Portal is optional - Dashboard and API work without it
# Skip portal errors if you don't need the Developer PortalNetwork "tyk" not found:
# Create external network
docker network create tyk
# Or remove "external: true" from docker-compose.ymlAfter successful bootstrap:
URL: http://localhost:3000
Email: admin@example.com
Password: topsecret123
# Get your API key from credentials file
API_KEY=$(grep "Test API Key:" bootstrap-output/bootstrap-credentials.txt | awk '{print $NF}')
curl http://localhost:8080/httpbin/get \
-H "Authorization: $API_KEY"
URL: http://localhost:3001
Email: portal-admin@example.com
Password: portalpass123
# Get credentials from file
DASH_KEY=$(grep "Dash Key:" bootstrap-output/bootstrap-credentials.txt | awk '{print $NF}')
ORG_ID=$(grep "Org ID:" bootstrap-output/bootstrap-credentials.txt | awk '{print $NF}')
# List APIs
curl http://localhost:3000/api/apis \
-H "Authorization: $DASH_KEY"
# List keys
curl http://localhost:3000/api/keys \
-H "Authorization: $DASH_KEY"