Shared directories
What survives a deploy: uploads, SQLite files and other folders kept between releases.
Every deploy is a new checkout of the repository in releases/<n>. What the app writes while it runs — uploads, generated files, an SQLite database — would stay behind in the old release. What must outlive a release lives in ~/shared and is linked into every new one: the .env, and the folders each type shares already. Anything else the app writes, you name once.
sudo cipi app edit shop --shared-dirs=public/uploads sudo cipi deploy shop
What each type shares already#
| App | Shared without asking | Add with --shared-dirs |
|---|---|---|
| Laravel and Octane | storage/ (the public disk, logs, sessions, cache), .env | A package that writes to public/ (public/uploads, public/media) |
| Symfony | var/log, var/sessions, .env.local | Uploads (public/uploads, a VichUploader mapping), var/data for an SQLite database |
| WordPress | The uploads folder (wp-content/uploads, web/app/uploads with Bedrock), .env, wp-config.php | What a plugin writes outside it: generated files, wp-content/languages when you let WordPress fetch translations |
| Laravel Rust and Laravel Go | storage/ — the public disk is served from it at /storage, no link to make — and .env | A disk outside storage/ |
| Node | .env | What the server writes: media, data |
| Custom | — its folder is the app, not a release | — |
Set the list#
sudo cipi app create --symfony --user=api --domain=api.example.com --shared-dirs=public/uploads,var/data sudo cipi app edit api --shared-dirs=public/uploads,var/data # the whole list sudo cipi app edit api --shared-dirs=none # only what the type shares sudo cipi app show api # Shared dirs
- The list is the whole list. It takes effect on the next deploy.
- The first deploy after a folder is added copies it from the release that is serving into
shared/, so what the app wrote there until then is kept. The copy is whole or not at all. - A folder taken off the list keeps its files in
~/shared/<dir>; new releases no longer link it. - Refused, with the reason: a path outside the repository or with
..;.git,.env,.ssh,vendor,node_modules; the code itself or what each release builds (public,app,src,config,public/build— a folder inside them is fine); a folder that overlaps what the type shares, or another one of the list; more than 10.
The same list in cipi.yml:
deploy:
shared_dirs:
- public/uploads
- var/dataA Node app declares its own as node.shared_dirs (Node apps). Previews get the same folders, empty; sudo cipi app clone and sudo cipi sync carry them with their files.
SQLite: kept, or the deploy stops#
An SQLite database inside the release is the one thing a deploy would lose without a word: the next checkout starts without it. A deploy that would do that stops before anything is built or migrated, and says where to keep the file:
| App | Where the database goes |
|---|---|
| Laravel | DB_DATABASE=/home/shop/shared/storage/database.sqlite (sudo cipi app env shop) |
| Laravel Rust | DATABASE_URL=sqlite://storage/app.db?mode=rwc |
| Laravel Go | DATABASE_URL=sqlite:storage/app.db |
| Symfony | DATABASE_URL="sqlite:///%kernel.project_dir%/var/data/app.db" and --shared-dirs=var/data |
| Any other folder | --shared-dirs=<that folder> |
The check reads DB_CONNECTION and DB_DATABASE (Laravel's default, empty, is database/database.sqlite: inside the release) and DATABASE_URL. When the release that is serving has the file, copy it to the new place first, as the app, then deploy again. A database file that comes with the repository is the repository's: the deploy goes on and says so. An in-memory database has nothing to keep.
sudo cipi app status reports the same before you deploy.
Common problems#
| Problem | Fix |
|---|---|
| Uploads gone after a deploy | The app writes them outside what its type shares: --shared-dirs=<that folder>, then deploy |
Shared directory 'public' is code or a build of each release | Share the folder inside it: public/uploads |
overlaps storage, which every laravel app shares already | It is shared already: nothing to do |
The deploy stops on The SQLite database of this app … is inside the release | Move the file as the table above says, then deploy again |
Questions#
| Question | Answer |
|---|---|
| Does it change anything on apps that exist? | No: nothing is shared that was not, until you set a list. |
| Is a shared folder backed up? | Yes: backups take shared/ with the rest of the app. |
| Where are the files on disk? | /home/<app>/shared/<dir>; each release has a link to it. |