# Deploy nimsforeststripe

## Prerequisites
- SSH access to land (46.225.164.179)
- Stripe API keys (test or live)
- NATS running on nimsforest.nimsforest.com:4222

## Initial Setup

1. Create config directory on land:
```bash
ssh root@46.225.164.179 "mkdir -p /opt/nimsforeststripe"
```

2. Create config:
```bash
ssh root@46.225.164.179 "cat > /opt/nimsforeststripe/config.yaml << 'EOF'
stripe:
  secret_key: \"sk_test_...\"
  webhook_secret: \"whsec_...\"

nats:
  url: nats://127.0.0.1:4222

http:
  port: 8097
  api_token: \"<generate-token>\"

sync:
  interval: 5m
EOF"
```

3. Build and start container:
```bash
ssh root@46.225.164.179 'docker run -d --name nimsforeststripe --network host --restart unless-stopped -v /opt/nimsforeststripe/config.yaml:/root/.nimsforeststripe/config.yaml:ro -e NATS_URL=nats://127.0.0.1:4222 registry.nimsforest.com/nimsforeststripe:<version>'
```

4. Create DNS record for webhook endpoint:
```bash
export HCLOUD_CONTEXT=nimsforest
hcloud dns rrset create --name stripe.myceliumland --type A --record 46.225.164.179 nimsforest.com
```

5. Create Stripe webhook in dashboard or via API pointing to:
   `https://stripe.myceliumland.nimsforest.com/api/v1/webhook/stripe`
   Events: `checkout.session.completed`

## Updating

Push a new `v*` tag to trigger CI/CD:
```bash
git tag v0.1.0
git push origin v0.1.0
```

The release pipeline will:
1. Build linux-amd64 and linux-arm64 binaries
2. Publish to releases.experiencenet.com
3. Build and push Docker image
4. Create GitHub release

## Rollback

1. SSH to land
2. Update container to previous version tag
3. Restart land
