Skip to content

Apply a changed .env

$ grim reload

You changed a value in .env, saved, refreshed the page, and the app behaves as if nothing happened. That is the moment for grim reload. A container reads its environment once, when it is created, and grim up never recreates one that is already running.

It matters most on a shared dev box, where you edit .env over VS Code Remote-SSH and the stack has been up for weeks.

Usage

$ grim reload              # recreate the stack, clear the config cache

Run it from the project directory or anywhere below it. It takes no arguments and no options.

Arguments and options

Recreate the Docker stack to apply .env changes (force-recreate + config:clear)

Usage

grim reload

What it actually does

Under the heading Reloading stack, each step printed with its result.

  1. Writes docker-compose.yml again, only on a shared dev box, where deployment.kind in grim.json is vps-dev. Changes to services, themes or the domain in grim.json land in the same run. On your own machine the compose file is not touched.
  2. Runs docker compose up -d --force-recreate. Every service is stopped and created again from the current .env and compose file. Volumes are kept, so the data in them is too.
  3. Runs php artisan config:clear in the app container, so a cached configuration cannot keep serving the old values. A failure here does not fail the run.

The app is away for the seconds the containers take to come back. Horizon is recreated with the rest, and a job that was running at that moment is interrupted.

Pitfalls

Hand edits to the compose file do not survive on a dev box

Step 1 replaces docker-compose.yml from the template on every reload, and so does grim up there. Put the change into grim.json, where the template reads it.

Vite is not part of it locally

On your own machine Vite runs on the host and grim reload leaves it alone. A changed VITE_ variable needs grim up, which stops the old Vite and starts a new one. On a dev box Vite is a container and is recreated with the others.

After it finishes

Refresh the page. The new value is live. To check what the app now sees, ask it.

$ grim artisan tinker

From your laptop, for a project on a dev box, grim server:dev:reload runs this same command on the box over SSH.

Recipes that use it