A reviewer opens a link and sees the branch running: the new checkout, the redesigned home page, the migration applied to real data. No pulling the branch, no "works on my machine", no shared staging that three people break at once.
Cipi has this built in. One command gives a branch its own address, its own database and its own HTTPS — a full copy of the app on the same server, deployed again at every push and removed when the branch is deleted.
sudo cipi preview create shop feature/new-cart
It works for every app that deploys releases from a repository: Laravel (PHP-FPM and Octane), WordPress, Symfony, Node and Laravel Rust.
Key ideas, in plain words#
| Term | Meaning |
|---|---|
| Preview | A copy of an app, on another branch of the same repository, with an address of its own. For Cipi it is simply one more app |
| Server domain | A domain that belongs to the server itself, not to one app: *.example.com. Cipi makes names under it for previews and webhooks |
| Wildcard DNS record | A record named * that sends every name under a domain to one server — anything.example.com included |
| Webhook | The call your Git provider makes after each push. It is what keeps a preview in step with its branch |
Before you start#
| You need | Why |
|---|---|
| A Cipi server with the app on it | The preview is made like that app: same type, PHP, build, deploy options |
| A domain whose DNS you control | For the wildcard record of step 1 |
| A Git provider token on the server (Git providers) | Recommended: Cipi adds each preview's deploy key and webhook, and removes them with it. Without one you add the key by hand |
| Free disk and RAM | A preview is a full app: a release, a database, a PHP pool or a Node process |
1. Give the server its own domain#
At your DNS provider, add one record that points at the server:
| Type | Name | Value |
|---|---|---|
A | * | the server's IPv4 address |
AAAA | * | its IPv6 address, if it has one |
Already using example.com for other things? Go a level down — name *.cipi, domain *.cipi.example.com — and nothing else under your domain is touched. A wildcard record never overrides the records you already have.
Then tell Cipi:
sudo cipi server domain set '*.example.com'
$ sudo cipi server domain set '*.example.com'
Cipi checks that the record really is a wildcard and really points here before it changes anything. Along with previews, the domain gives every app a Git webhook on https://webhooks.example.com/<app> — so a Laravel app deploys on push without the cipi/agent package (server domain). In the panel: the server's Domain section.
2. Create a preview#
Push the branch, then:
sudo cipi preview create shop feature/new-cart
$ sudo cipi preview create shop feature/new-cart --db=copy
The address is <app>-<branch>-<random>.<domain>: shop-feature-new-cart-7asfy.example.com. The five random characters mean two previews never collide and the address is hard to guess — though not a secret: keep private previews behind basic auth.
Same type, PHP version, Node version, build command, document root and deploy options. A Linux user, a PHP pool (or a Node process), a deploy key and a webhook of its own.
Everything is carried over except the app's keys and salts, its URLs, its database, its Valkey, Reverb and search settings: the preview gets its own.
New and empty, or a copy of the app's. Never the app's database.
A Let's Encrypt certificate for its name, then the first deploy of the branch.
| Option | What it does |
|---|---|
--db=empty | A new, empty database: the first deploy runs the migrations. The default |
--db=copy | A copy of the app's database, taken now |
--db=none | No database (not for a Laravel app) |
--no-deploy | Create it, deploy later — to change its .env first |
--keep | Stays when its branch is deleted |
--no-ssl | No certificate now |
From the app's side it reads the same: sudo cipi app feature-branch shop feature/new-cart. The preview's name — shopfeaturenew7asfy here — is the Linux user and the database; the command prints it, and sudo cipi preview list lists them all.
A preview is an app. Everything you know works on it by its name: sudo cipi deploy, sudo cipi app logs, sudo cipi app env, sudo cipi app run, sudo cipi basicauth, sudo cipi worker add.
3. Choose its data#
| Use it when | Mind | |
|---|---|---|
| Empty (default) | The app seeds itself; the change is code, not data | Run your seeders once: sudo cipi app artisan <preview> db:seed --force (Laravel), or the console command of your framework |
| Copy | A migration or an upgrade must be tried on real data; a WordPress or WooCommerce site whose content is the data | Personal data travels with it. For Laravel, an anonymized dump is safer for previews many people open |
| None | A Node front end with no database of its own | — |
A copy is taken once, when the preview is made. Later pushes run the branch's migrations on that copy, never on production.
4. Every push updates it#
A push to the branch deploys the preview, the way a push deploys the app: a new release beside the live one, one switch. The preview's webhook is on the server's domain — https://webhooks.example.com/<preview> — and is registered on the repository with the provider token.
sudo cipi app webhook show shopfeaturenew7asfy # where its pushes go sudo cipi app webhook auto shopfeaturenew7asfy off # stop following the branch for now sudo cipi deploy shopfeaturenew7asfy # deploy it by hand
5. Keep it safe#
A preview is a real app on the internet, with a copy of your configuration. Four things to decide once:
| What to do | |
|---|---|
The .env is copied with the mail settings. Create with --no-deploy, then point mail away from real people — MAIL_MAILER=log (Laravel), MAILER_DSN=null://null (Symfony), an SMTP sandbox such as Mailpit — and deploy | |
| Payments and APIs | Swap live keys for test keys: Stripe, PayPal, webhooks to third parties, a separate storage bucket |
| Privacy | Basic auth keeps search engines and strangers out: sudo cipi basicauth enable <preview>. Its webhook is on the server's domain, so pushes still deploy. For company logins, put previews behind Cloudflare Zero Trust |
| Data | With --db=copy, the preview holds what production holds. Give it only to people who may see it, or use an anonymized dump |
sudo cipi preview create shop feature/new-cart --db=copy --no-deploy sudo cipi app env shopfeaturenew7asfy --set=MAIL_MAILER=log sudo cipi app env shopfeaturenew7asfy --set=STRIPE_SECRET=sk_test_… sudo cipi basicauth enable shopfeaturenew7asfy --user=review sudo cipi deploy shopfeaturenew7asfy
6. A configuration just for previews#
A preview's environment is preview. When the app applies its cipi.yml after every deploy, the preview reads cipi-preview.yml first, if the repository has one. Keep previews small:
# cipi-preview.yml
version: 1
workers:
queues:
- { queue: default, processes: 1 } # one worker is plenty for a review
schedule: false # no scheduled jobs on previews
deploy:
keep_releases: 2 # less disk per previewTurn auto-apply on for the app — sudo cipi yml auto shop on — and each new preview has it on too.
7. From the panel#
Every app that can have previews has a Previews section: type a branch, pick the database, tick Keep if it is for a demo, create. The list shows each preview with its address, its database, whether pushes deploy it, and a delete button.
In the Apps list, previews sit under the app they come from, called by their branch, so a server with twenty previews still reads as five apps:
A preview's own page says whose preview it is, and has every section an app has — logs, environment, commands, deploys.
8. One preview per pull request, from CI#
The built-in command needs no script: a pipeline calls the REST API once when a pull request opens, and deleting the branch after the merge does the rest. On the server, a token that may only create previews and touch their .env and deploys:
sudo cipi api token create --name=previews \
--abilities=apps-view,apps-create,apps-env,deploy-manage --expires=2027-12-31Save it as CIPI_API_TOKEN and the API's address as CIPI_API_URL in the repository's secrets. Then:
# .github/workflows/preview.yml name: Preview on: pull_request: types: [opened, reopened] jobs: preview: runs-on: ubuntu-latest steps: - name: Create the preview of the branch env: API: ${{ secrets.CIPI_API_URL }} TOKEN: ${{ secrets.CIPI_API_TOKEN }} BRANCH: ${{ github.head_ref }} run: | H="Authorization: Bearer $TOKEN" wait_job() { # poll a job until it ends; print its result for i in $(seq 1 180); do j=$(curl -fsS "$API/api/jobs/$1" -H "$H") case "$(jq -r '.data.status' <<< "$j")" in completed) jq -c '.data.result' <<< "$j"; return 0 ;; failed) jq -r '.data.output' <<< "$j"; return 1 ;; esac sleep 5 done return 1 } # 1. the preview, with a copy of the database, not deployed yet job=$(curl -fsS -X POST "$API/api/apps/shop/previews" -H "$H" -H "Content-Type: application/json" \ -d "$(jq -n --arg b "$BRANCH" '{branch: $b, db: "copy", deploy: false}')" | jq -r '.job_id') result=$(wait_job "$job") name=$(jq -r '.preview' <<< "$result"); url=$(jq -r '.url' <<< "$result") # 2. no real e-mail, test keys curl -fsS -X PUT "$API/api/apps/$name/env" -H "$H" -H "Content-Type: application/json" \ -d '{"set":{"MAIL_MAILER":"log","STRIPE_SECRET":"sk_test_..."}}' > /dev/null # 3. the first deploy wait_job "$(curl -fsS -X POST "$API/api/apps/$name/deploy" -H "$H" | jq -r '.job_id')" > /dev/null echo "### Preview: $url" >> "$GITHUB_STEP_SUMMARY"
From then on, pushes to the branch deploy the preview through its own webhook, and the branch deletion after the merge removes it. On GitLab, the same three calls go in a job with rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event". The cipi-cli and the PHP SDK have the same commands: cipi-cli previews create shop feature/new-cart, $cipi->previews()->create('shop', 'feature/new-cart', ['db' => 'copy']).
Want previews made and removed by your pipeline instead — for every pull request, closed with it, on a server of their own, with a script you control? That is the pipeline-driven way. Both can live side by side.
9. When it goes#
| What happens | The preview |
|---|---|
| The branch is deleted on the Git provider | Removed within a few minutes — Cipi asks the repository itself before it deletes anything |
| The branch is merged, and kept | Stays. Turn on Automatically delete head branches (GitHub) or Delete source branch (GitLab) |
| The repository can't be reached | Stays: a network error is never read as a deleted branch |
It was made with --keep | Stays until you delete it |
| You delete it | sudo cipi preview delete shopfeaturenew7asfy, or the panel's delete button |
Removing a preview removes its address, certificate, database, files, and its deploy key and webhook on the repository. A check every five minutes does the sweeping; a preview without a webhook is asked about every half hour.
sudo cipi preview list # every preview on the server sudo cipi preview list shop # those of one app sudo cipi preview keep shopfeaturenew7asfy on sudo cipi preview delete shop feature/new-cart
Good to know#
| The app's own branch | Is not a preview: a preview of main, when the app deploys main, is refused |
| One per branch | A second preview of the same branch is refused, with the name of the first |
| A preview of a preview | Refused: make it from the app |
| Workers | A Laravel preview gets its queue worker and scheduler like the app (tune them in cipi-preview.yml). A Symfony preview starts with none: sudo cipi worker add <preview> --queue=async |
| Media of a WordPress copy | The preview's uploads folder starts empty; copy it if reviewers need the images |
| A public repository that is not yours | The preview is made, and deploys when you ask: nobody but the owner can add a webhook to it |
| Behind a Cloudflare tunnel or a mesh lock | Ports 80 and 443 are closed to the world, so previews and webhooks.<domain> can't be reached directly. Publish a branch through the tunnel with sudo cipi zt preview create |
| Changing the server's domain | Refused while previews live under it: delete them first |
Troubleshooting#
| Problem | Fix |
|---|---|
| Previews live under the server's domain, and none is set | Step 1: sudo cipi server domain set '*.example.com' |
| … is not a wildcard | You created webhooks.example.com only: add the * record |
| The repository of 'shop' has no branch … | Push the branch first. The command lists the branches it found |
| Deploy: not run — the preview's deploy key cannot read the repository yet | No provider token: sudo cipi deploy <preview> --key, add it to the repository as read-only, then sudo cipi deploy <preview> |
| A custom app has no previews | Custom apps have no releases. Move the app to its type (WordPress, Symfony) if it lives in Git |
| The preview shows production's links (WordPress) | Links inside posts point at the live domain: sudo cipi app run <preview> wp search-replace 'https://blog.example.com' 'https://<preview address>' --all-tables |
| Pushes don't update it | sudo cipi app webhook show <preview>: whether the provider has the hook, and whether automatic deploys are on |
| It is still there after the merge | The branch wasn't deleted. Delete it, or sudo cipi preview delete <preview> |
Every command and option: Preview environments in the docs.
Questions
What does a preview cost?
Nothing in licences: it is one more app on a server you already pay for. It takes disk (a release, a database) and some RAM while it runs. Delete the ones nobody looks at — or let the branch deletion do it.
Which apps can have previews?
Laravel (PHP-FPM and Octane), WordPress, Symfony, Node and Laravel Rust apps — every type that deploys releases from a repository. A custom app has no releases to preview.
Do I need a wildcard certificate?
No. Each preview gets a normal Let's Encrypt certificate for its own name. What you need is a wildcard DNS record, which every DNS provider offers for free.
Is my production database at risk?
No. A preview never uses the app's database: it gets a new one, empty or a copy taken when the preview is made. Writes on the preview stay there.
Does a preview send e-mails to real users?
It can: the app's .env is copied, mail settings included. Create it with --no-deploy, point mail at a log or a sandbox with sudo cipi app env <preview>, then deploy. The pipeline recipe below does it for you.
What happens when the branch is merged?
If your Git provider deletes merged branches (turn it on), the preview goes within minutes. A merged branch that is kept keeps its preview until you delete it.
Can I keep a preview for a demo?
Yes: --keep when you create it, or sudo cipi preview keep <preview> on later. It stays when its branch is deleted, until you remove it.
Can previews live on another server than production?
Yes, and for busy teams it is the better setup: one Cipi server for previews, with its own domain, and production left alone. The app has to exist there too — cipi sync copies it.