Take a project off the box
$ grim server:dev:remove shop --keep-volumes
A project is finished, moved to another box, or was added under the wrong name. grim server:dev:remove clears it off the dev box: containers, data, code and your registration of it. The box itself, Traefik and every other project stay as they are.
By default it removes everything. The two --keep flags are how you hold something back.
Usage
$ grim server:dev:remove shop # everything, after a confirmation
$ grim server:dev:remove shop --keep-volumes # leave the database and Redis data
$ grim server:dev:remove shop --keep-repo # leave the directory with the code
$ grim server:dev:remove shop --yes # no confirmationRun it from the machine that added the project. It finds the box and the path in the dev environment of the project in your ~/.grim/servers.json.
Arguments and options
Remove a dev project from its VPS (stop containers, optionally drop volumes / repo)
Usage
grim server:dev:remove [--keep-volumes] [--keep-repo] [-y|--yes] [--] <project>Arguments
| Argument | Description |
|---|---|
project |
Project name (required) |
Options
| Option | Description |
|---|---|
--keep-volumes |
Keep DB and other volumes (default: drop them) |
--keep-repo |
Keep the cloned repo on the VPS (default: delete) |
-y, --yes |
Skip confirmation prompt |
What it actually does
- Shows what is about to go and asks
Continue? [y/N]. The summary names the project, the path and host, and says for volumes and for the directory whether each is kept. Anything but yes ends withAborted.and nothing touched.--yesskips this. - Stops the stack.
docker compose down -vin the project directory, or plaindocker compose downwith--keep-volumes. A failure here is a warning and the run goes on, so a stack that was already down does not block the removal. - Deletes the project directory, unless
--keep-repo. It refuses any path outside/home/dev/projects/. - Removes the
devenvironment of the project from yourservers.json. Other environments of the same project, such as production, stay registered.
What goes and what the flags keep
| Default | --keep-volumes |
--keep-repo |
|
|---|---|---|---|
| Containers and network | Removed | Removed | Removed |
| MySQL and Redis volumes | Deleted | Kept | Deleted |
/home/dev/projects/<project> |
Deleted | Deleted | Kept |
.env with its passwords |
Deleted | Deleted | Kept |
Entry in your servers.json |
Removed | Removed | Removed |
On a dev box the database is a volume of the project's own stack. Without --keep-volumes it is deleted for the whole team, and there is no copy unless somebody made a dump. Work that was never pushed goes with the directory in the same way.
Pitfalls
Kept volumes without the .env are hard to get back into
--keep-volumes alone deletes the directory, and with it the .env that holds the database passwords. A project added again gets new passwords, which the MySQL data in the old volume does not accept. To keep data you mean to use again, pass both --keep-volumes and --keep-repo.
The registration goes even when you keep everything
With both flags the box still holds a complete, stopped project, but grim server:dev:info and grim server:dev:reload no longer know it from your machine. Running grim server:dev:add-project again over the kept directory registers it anew and starts it.
DNS records and certificates are not yours to forget
Nothing outside the box is cleaned up. The three DNS records of the project still point at the server until you delete them.
After it finishes
The project's URLs answer with Traefik's 404, because no container claims them any more. The rest of the box is unchanged, and a developer who had the directory open in an editor will find the window pointing at nothing.
Related spells
grim server:dev:add-project
Settle a project on the box
Clone a repository onto a shared dev box, give it a dev .env and domains, and start its stack there.
grim server:dev:info
Show a project's dev card
Print the URLs, SSH and VS Code commands, database credentials and container states of a project on a dev box.
grim server:dev:reload
Recreate a dev stack
Recreate the containers of a project on a dev box from your own machine, so a changed .env or grim.json takes effect.
grim server:dev:setup
Raise a shared dev box
Turn a bare VPS or LAN machine into a shared development server with Docker, Traefik, one dev user and grim itself.