Skip to content

Stop make clean from tearing down the production stack #476

Open

Description

@HMarzban

Summary

make clean runs docker compose … down -v on the production stack when production containers are up. On a production server that is a full outage: it stops and removes every production container. It then deletes the redis-data and traefik-certs volumes.

  • Severity: Medium. A person must run the command on a production host. But the self-hosting guide installs with make from a checkout on that host, and the help text gives no warning.
  • Area: Makefile, README.md
  • Source: repository review of 2026-10-14

Where

  • Makefile:338–342: the production branch of clean runs docker compose -f docker-compose.prod.yml --env-file .env.production down -v.
  • docker-compose.prod.yml:47 sets name: docsplus. So the ps -q check finds the production stack from any checkout on the host that holds .env.production. Without that file, Compose stops with couldn't find env file, and the check finds nothing (measured).
  • Volumes the command deletes (docker-compose.prod.yml:654–658):
    • redis-data holds the Redis append-only file, so it holds the BullMQ queues (see Require a password on production Redis #438). Pub/sub messages are never stored there.
    • traefik-certs holds the TLS certificates. Traefik must reissue every certificate on the next start.
  • The dev branch can reach production too. docker-compose.dev.yml and docker-compose.local.yml set no name:, so Compose names the project after the checkout folder. Measured: a folder named docs.plus, the default clone folder, gets the project name docsplus. If that checkout also has .env.development, the dev branch runs first. Its down then removes the production containers whose service names match: redis, rest-api, hocuspocus-server, hocuspocus-worker, webapp and admin-dashboard (read from code, not measured). traefik stays. The production volumes stay too, because the dev file does not declare them.
  • Makefile:58 describes clean as "Clean everything (auto-detects dev/prod/local)". README.md:224 does say "DATA LOSS".
  • docs/self-hosting/install.md:147 and :165 tell self-hosters to run make build and make up-prod in their checkout. That checkout holds .env.production.
  • docsy-postgres-prod and docsy-redis-prod in the docker volume rm list (Makefile:350) are dead. A repo-wide search finds those names only on that line.

Fix plan

  1. Make the production check the first branch of clean, and make it refuse:

    @if docker compose -f docker-compose.prod.yml --env-file .env.production ps -q 2>/dev/null | grep -q .; then \
    	echo "⛔ The production stack is running. make clean does not touch it."; \
    	echo "   To stop it on purpose: docker compose -f docker-compose.prod.yml --env-file .env.production down"; \
    	exit 1; \
    elif … dev branch …

    The dev and local branches stay as they are. Deleting the production branch is not enough. A running production stack would then fall through to the last branch. That branch prints "No running containers found" and tries to remove the production :latest images.

  2. Remove docsy-postgres-prod and docsy-redis-prod from the docker volume rm list.

  3. Change the help line at Makefile:58 to "Clean dev or local containers and volumes (DATA LOSS)". Change README.md:224 to match.

Out of scope

  • A confirmation prompt. The fix is a hard stop.
  • Giving the dev and local compose files their own name:. File it separately if wanted. Until then, a docs.plus checkout that has .env.development but no .env.production can still reach production through the dev branch.
  • Changes to the other make targets.
  • A laptop that holds .env.production and runs the backend-local stack (docker-compose.backend-local.override.yml, also name: docsplus). There, the refusal fires with the production message. Stop that stack first.

Acceptance criteria

  • From a checkout that holds .env.production, with the production stack up, make clean exits non-zero and prints the refusal. Every production container and volume stays in place.
  • make help and README.md:224 no longer say that clean handles production. The docker volume rm list no longer names docsy-postgres-prod or docsy-redis-prod.
  • With no production stack, make clean tears down a running dev or local stack as before.

Verify

  1. Run make -n clean. Check that the production check comes first and that its branch only prints and exits.
  2. On a throwaway machine or VM only, start the production stack and run make clean. Starting only redis is enough for the check: docker network create docsplus-network, then docker compose -f docker-compose.prod.yml --env-file .env.production up -d redis. Check the exit code and docker ps. Do not run this on a machine whose local data you need, because the local branch runs down -v.

Related


Generated by Claude Code

Activity

  1. added
    bug
    on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DevOpsbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions