Deploying to a container host
Many hosts build the Laravel app into a container and run it from a start command: Sevalla, Railway, Fly.io, Render and others. They differ from a server you manage in two ways that matter to Nevela:
- There is often no cron, and no switch for Laravel’s scheduler as on Laravel Cloud.
- The container’s own files go at each deploy. Only a disk you add lasts, and it often belongs to one process: a second process (a separate worker or cron service) can’t write where the web process reads.
So run everything the app needs in the one container, beside the web server, and keep what must last on the disk. Everything in Deploying still applies. This page covers what is different.
The start command
Section titled “The start command”php artisan migrate --force \ && php artisan storage:link \ && php artisan optimize \ && (php artisan schedule:work &) \ && exec <start the web server><start the web server> is what your host runs by default. On Sevalla it is /usr/local/bin/ingot-laravel-start. Ending on exec makes the web server the container’s main process, so the host’s restarts and health checks reach it.
A disk that lasts
Section titled “A disk that lasts”Add a persistent disk and mount it at storage/app in the Laravel app. That folder holds:
- Uploads. Images and files go to the
publicdisk (storage/app/public) unlessNEVELA_UPLOADS_DISKnames another; private files go tostorage/app/private.php artisan storage:linkin the start command linkspublic/storageto them again in each new container. - The SQLite database, if you use one: set
DB_DATABASEto its full path on the disk, for example/app/storage/app/database.sqlitewhere the app is in/app.
With a managed database (Postgres, MySQL) instead, only the uploads need the disk. Or set NEVELA_UPLOADS_DISK to an S3-compatible disk and the container needs no disk at all.
Keep CACHE_STORE on database (or Redis). Sign-in codes, links and rate limits live in the cache, and so does the sign the scheduler leaves for nevela deploy:check.
The queue
Section titled “The queue”Form notices and confirmation emails are queued. Without a separate worker, pick one of these:
QUEUE_CONNECTION=deferred: each job runs right after its request has been answered, in the same process. It needs no worker.QUEUE_CONNECTION=sync: each job runs while the visitor waits. It works, but a slow mail server slows the request.- A worker in the same container: add
(php artisan queue:work --tries=3 &) &&to the start command, before the scheduler, and keepQUEUE_CONNECTION=database.
The scheduler
Section titled “The scheduler”The scheduler empties the trash each night, removes ended sign-ins and sends the hourly digest of form notices. Where there is no cron, php artisan schedule:work does cron’s job: it stays running and starts each task at its time. The (php artisan schedule:work &) in the start command runs it beside the web server, so it writes to the same disk and cache the web process reads.
Until it has run, the bell tells administrators The scheduler isn’t running. It leaves a sign every 5 minutes, so after a deploy give it 5 minutes.
Caching config and routes
Section titled “Caching config and routes”php artisan optimize caches the config, routes, events and views, which many hosts run on start. That is fine from Nevela 0.33.1.
On 0.33.0 and earlier, don’t cache routes. With routes cached, every sign-in and every public route answered with a 500 (Rate limiter [nevela-auth] is not defined, Target class [nevela.throttle] does not exist). Cache the rest one by one instead (config:cache, event:cache, view:cache), or upgrade.
Checking it
Section titled “Checking it”Once it is deployed, open a shell in the container and run:
php artisan nevela:deploy:checkIt checks the environment, migrations, cache, scheduler, queue, mail and the dashboard, and says what to change for each problem. See nevela deploy:check.