Step 6: First deploy (staging)
Create the whole staging environment with one Deploy workflow run, what happens in which order, and how to check each piece.
Goal: staging fully running: API on api-staging.lynkoria.com behind Cloudflare, media and scanner Droplets healthy, console and docs published.
6.1 The first-run DNS switch
App Platform must validate api-staging.lynkoria.com and issue its certificate before Cloudflare proxies the record. For the first run only, set the staging variable API_DNS_PROXIED to false (step 4.3). You remove it in 6.4.
6.2 Run
Actions → Deploy → Run workflow → environment: staging (or merge to main, which deploys staging after CI). The run has four jobs:
| Job | What happens |
|---|---|
preflight | Checks the environment has its token, passphrase and state bucket |
images | Confirms CI passed for the commit; builds, pushes and Trivy-scans lynkoria-api and (when its sources changed) lynkoria-scanner |
infrastructure | infra/opentofu/run.sh staging apply with the two image digests, then a smoke test |
static | Builds the console and docs with the API and site URLs from OpenTofu's outputs, checks bundles for secrets, publishes to Pages |
During tofu apply, in dependency order:
- Generated secrets: pepper, webhook master, LiveKit key pairs, messaging signing key, scanner token, scanner CA and certificate.
- VPC; PostgreSQL (database,
lynkoria_app,lynkoria_migrate, transaction pool, VPC-only trusted source); Valkey (noeviction, VPC-only). - Database grants:
scripts/apply-grants.shadds the runner's IP as a temporary trusted source, appliesfiles/database-grants.sqlas the admin user over verified TLS, and removes the rule. - Spaces bucket with lifecycle rules and CORS, and the API's bucket-scoped key.
- Media Droplet (cloud-init installs LiveKit, Caddy, Redis), its firewall, DNS for
rtc-stagingandturn-staging(DNS only). - Scanner Droplet (cloud-init pulls the scanner image with read-only registry credentials and starts
infra/scanner/compose.yaml), its firewall, and the private DNS record. - Cloudflare Access policy and application; Pages projects, custom domains and their DNS records.
- App Platform app: migrations (PRE_DEPLOY), the
apiservice, the owner bootstrap (POST_DEPLOY). - The
api-stagingCNAME to the app.
Expect 20–40 minutes the first time.
6.3 Check the pieces
The workflow's smoke test already checked https://api-staging.lynkoria.com/health/ready and that the *.ondigitalocean.app address answers 403. Also check:
curl -sI https://rtc-staging.lynkoria.com | head -1
dig +short rtc-staging.lynkoria.com turn-staging.lynkoria.com
curl -sI https://console-staging.lynkoria.com | grep -iE 'content-security-policy|strict-transport'Caddy gets the media certificates a few minutes after DNS points at the Droplet. To look inside the Droplets, use the IPs from the outputs (the workflow log prints them, or run infra/opentofu/run.sh staging output locally, see operate):
ssh root@MEDIA_PUBLIC_IP 'cloud-init status --long; cd /opt/livekit && docker compose ps'
ssh root@SCANNER_PUBLIC_IP 'cloud-init status --long; docker compose -f /opt/lynkoria-scanner/compose.yaml ps'The scanner reports healthy only after ClamAV's first signature download, which can take several minutes.
6.4 Turn on the Cloudflare proxy
When the App Platform domain is Active (DigitalOcean control panel → the app → Settings → Domains), delete the API_DNS_PROXIED variable (the default is true) and run Deploy for staging again. OpenTofu switches the record to proxied. From then on, the origin lock is the only way in.
curl -sI https://api-staging.lynkoria.com/health/ready | grep -i cf-rayIf anything fails, the error names the resource; see troubleshooting. A rerun continues from where it stopped.
Next: Step 7: First sign-in.
Step 5: Zone stack
Apply the shared Cloudflare zone stack — TLS settings, per-environment origin-lock secrets and rules, API cache bypass, www redirect, DMARC and CAA.
Step 7: First sign-in
Create the owner's console password, sign in through Cloudflare Access, create a project and key, and run the control-plane smoke test.