Refresh a project's server files
$ grim server:upgrade shop --restart
The compose file on a server was written by the grim you had on the day the project was added. Since then grim self-update has brought newer templates, or you have switched Horizon or Reverb on in grim.json, and the server knows nothing of it. grim server:upgrade writes the two files again from what you have now.
Most of the time you do not need it. grim deploy sends the same two files before every deployment, so a release that is going out anyway carries the change with it. Reach for this command when the files must change and no new version is due.
Usage
$ grim server:upgrade shop # write the files, leave the containers alone
$ grim server:upgrade shop --restart # write them and recreate the containers
$ grim server:upgrade shop --host=vps1 # another host than the one on recordRun it from the project directory. That is where it reads grim.json, and the pitfalls below show what happens without it.
Arguments and options
Sync Docker configuration files to server (docker-compose.yml, nginx config)
Usage
grim server:upgrade [--host HOST] [--restart] [--] <project>Arguments
| Argument | Description |
|---|---|
project |
Project name (required) |
Options
| Option | Description |
|---|---|
--host=HOST |
Server host or alias (overrides saved config) |
--restart |
Restart changed containers after sync |
What it actually does
- Finds the server and the domain in the project's record in
~/.grim/servers.json. - Reads
grim.jsonin the current directory: whether the project runs Horizon and Reverb, and which image it pulls. - Writes
/opt/shop/docker-compose.ymlfrom the current template. Domains attached withgrim server:add-domainare kept in the Traefik rule. - Uploads
docker/nginx-production.conf, the configuration of the nginx inside the project's stack. - Recreates the containers, only with
--restart, throughdocker compose up -d --force-recreate.
Without --restart the summary reminds you that nothing is applied yet. The files wait for the next deploy or for a restart of your own. The .env, the host's nginx vhost and Traefik are not touched.
Three commands, three jobs
| Rewrites | Horizon and Reverb come from | Containers | |
|---|---|---|---|
grim server:upgrade |
The project's compose file and in-container nginx config | grim.json in the current directory |
Left alone unless --restart |
| grim server:sync-compose | The project's compose file, and makes .env writable for the app |
The compose file already on the server | Recreated unless --no-recreate |
| grim server:upgrade-traefik | The host's shared Traefik compose file | Not applicable | Traefik recreated unless --no-restart |
Pitfalls
Outside the project directory it writes a poorer file
With no grim.json to read, the compose file is rendered without Horizon and without Reverb, and with the default image name instead of the one grim.json sets. Run it from the project, or use grim server:sync-compose, which reads the services from the server instead.
--restart recreates every container
Not only the ones whose definition changed. The site is interrupted while they come back. Pick a quiet moment, or leave the restart to the next release.
Without a domain it refuses to start
The message begins shop has no domain, and there is no default one. The domain comes from the project's record in servers.json, and there is no default to fall back on. Run the command on the machine that registered the project with grim server:add-project.
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
Check that the stack came back the way you meant it to.
$ grim server:status vps1Questions
Should I run it before every release?
No. The deploy step of a release sends the same files first. This command is for the days between releases.
Is this the server side of grim upgrade?
Yes. grim upgrade rewrites the Docker files of your local project from the templates of the installed grim. This command does the same for the two files a deployed project keeps on its server.
Related spells
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:sync-compose
Rebuild a server's compose file
Re-render a project's docker-compose.yml on its server from the current template, keeping the services it already runs, and recreate the containers.
grim upgrade
Renew the infrastructure files
Rewrite the Docker and nginx files of a project from the templates of the grim you have installed.
grim deploy
Send an image to a server
Roll a pushed image tag out to one environment over SSH, verify the app answers, and fall back to the previous tag when it does not.
grim self-update
Update grim itself
Replace the grim phar with the newest release. Projects are not touched.