Skip to content

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 confirmation

Run 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

  1. 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 with Aborted. and nothing touched. --yes skips this.
  2. Stops the stack. docker compose down -v in the project directory, or plain docker compose down with --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.
  3. Deletes the project directory, unless --keep-repo. It refuses any path outside /home/dev/projects/.
  4. Removes the dev environment of the project from your servers.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.

Recipes that use it