Skip to content
Nevela 0.33.1: New: customers get a shop in the mobile app, each sees only their own orders, and an administrator manages people and roles from the phone. Build it in the new drinks-app tutorial.A drinks app on the phone

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.

Terminal window
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.

Add a persistent disk and mount it at storage/app in the Laravel app. That folder holds:

  • Uploads. Images and files go to the public disk (storage/app/public) unless NEVELA_UPLOADS_DISK names another; private files go to storage/app/private. php artisan storage:link in the start command links public/storage to them again in each new container.
  • The SQLite database, if you use one: set DB_DATABASE to its full path on the disk, for example /app/storage/app/database.sqlite where 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.

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 keep QUEUE_CONNECTION=database.

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.

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.

Once it is deployed, open a shell in the container and run:

Terminal window
php artisan nevela:deploy:check

It checks the environment, migrations, cache, scheduler, queue, mail and the dashboard, and says what to change for each problem. See nevela deploy:check.