Rebuild a server's compose file
$ grim server:sync-compose shop
A server still runs the compose file it got on the day the project was added, the template has changed since, and you are not sitting in the project's checkout. That is the case for this command. It needs nothing but the project's record in your ~/.grim/servers.json: what the stack consists of, it reads from the server.
From inside the project directory, grim server:upgrade is the better tool, because it also honours what grim.json says. The two are compared there.
Usage
$ grim server:sync-compose shop # write the file and recreate the containers
$ grim server:sync-compose shop --no-recreate # write the file, leave the containers aloneRun it from anywhere. The project must have been registered with grim server:add-project on this machine.
Arguments and options
Re-render docker-compose.yml on a server from the current template and recreate containers
Usage
grim server:sync-compose [--no-recreate] [--] <project>Arguments
| Argument | Description |
|---|---|
project |
Project name (as registered via server:add-project) (required) |
Options
| Option | Description |
|---|---|
--no-recreate |
Upload new compose but do not restart containers |
What it actually does
- Looks the project up in
servers.jsonfor its host, domain and path. - Reads the compose file on the server to see whether it has a Horizon and a Reverb service. The new file gets the same ones.
- Writes
/opt/shop/docker-compose.ymlfrom the current template, with the domains attached bygrim server:add-domainkept in the Traefik rule. - Makes
.envwritable for the app. The container'swww-datauser gets write access to/opt/shop/.env, which the current template mounts into the containers as a file. - Recreates every container of the project with
docker compose up -d --force-recreateand shows Docker's output. Skipped with--no-recreate.
Pitfalls
An image name set in grim.json is lost
The command never reads grim.json, so docker.image and docker.owner do not reach the new file. It names the default image. For a project that pulls from its own namespace, use grim server:upgrade from the project directory instead.
The site is interrupted
Recreating every container takes the app away for a moment. With --no-recreate the new file waits on the server until the next deploy or until you restart the stack yourself.
The project is not on record
Project 'shop' not found. Run server:add-project first. means this machine's servers.json does not know the project. It is a local record, not a fact about the server. Run the command where the project was registered.
Only the default environment
There is no --env. The command works on the project's default environment, the first one you registered.
After it finishes
The last line suggests a check to run on the server, inside /opt/shop. It lists the mounted .env as the app container sees it.
$ docker compose exec app ls -la /var/www/html/.envRelated spells
grim server:upgrade
Refresh a project's server files
Send the current docker-compose.yml and in-container nginx config to a project's server, without deploying a new image.
grim server:upgrade-traefik
Renew a server's Traefik
Re-render the shared Traefik compose file of a production server from the current template and recreate the container.
grim server:status
Look over a server
List the servers you have registered, or look at one of them: its containers, its disk, Traefik and its projects.
grim self-update
Update grim itself
Replace the grim phar with the newest release. Projects are not touched.