Skip to Content
LYNKORIADocs

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:

JobWhat happens
preflightChecks the environment has its token, passphrase and state bucket
imagesConfirms CI passed for the commit; builds, pushes and Trivy-scans lynkoria-api and (when its sources changed) lynkoria-scanner
infrastructureinfra/opentofu/run.sh staging apply with the two image digests, then a smoke test
staticBuilds 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:

  1. Generated secrets: pepper, webhook master, LiveKit key pairs, messaging signing key, scanner token, scanner CA and certificate.
  2. VPC; PostgreSQL (database, lynkoria_app, lynkoria_migrate, transaction pool, VPC-only trusted source); Valkey (noeviction, VPC-only).
  3. Database grants: scripts/apply-grants.sh adds the runner's IP as a temporary trusted source, applies files/database-grants.sql as the admin user over verified TLS, and removes the rule.
  4. Spaces bucket with lifecycle rules and CORS, and the API's bucket-scoped key.
  5. Media Droplet (cloud-init installs LiveKit, Caddy, Redis), its firewall, DNS for rtc-staging and turn-staging (DNS only).
  6. 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.
  7. Cloudflare Access policy and application; Pages projects, custom domains and their DNS records.
  8. App Platform app: migrations (PRE_DEPLOY), the api service, the owner bootstrap (POST_DEPLOY).
  9. The api-staging CNAME 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-ray

If anything fails, the error names the resource; see troubleshooting. A rerun continues from where it stopped.

Next: Step 7: First sign-in.

On this page