Skip to content

Latest commit

 

History

History
74 lines (66 loc) · 4.01 KB

README.md

File metadata and controls

74 lines (66 loc) · 4.01 KB

Development utility scripts

  • dev-up.sh — build and start the dev stack (docker-compose-dev.yml), print the host URL of every running service (reflecting worktree port remaps and enabled profiles), then follow the logs; Ctrl-C stops the stack. -d returns after printing the URLs; other arguments are forwarded to docker compose up. Enable profiles with COMPOSE_PROFILES, e.g. COMPOSE_PROFILES=zimfarm ./scripts/util/dev-up.sh.
  • run_tests.sh — run the backend test suite. Starts the test containers (docker-compose-test.yml) if they aren't already running, cleans dirty tables left behind by interrupted runs, then runs pipenv run pytest (arguments are forwarded, e.g. ./scripts/util/run_tests.sh wp1/tables_test.py).
  • check_types.sh — run ty type checking against the subset of files that are fully annotated (the list lives in the script itself and is the single source of truth; CI invokes it directly).
  • seed-dev-selections.py — seed the dev database with test Selection data; see docker/dev-db/README.md.
  • create_worktree.sh — set up a git worktree with its own parallel dev stack, described below.

Running parallel dev stacks (e.g. from git worktrees)

The easiest way is ./scripts/util/create_worktree.sh <branch>, which creates the worktree under .worktrees/<branch>, writes a worktree-local .env (based on the main checkout's .env, if present) with a unique project name, suffix, and free port set (remapping the port-coupled app config values to match), and offers to start the stack ("Start servers now? [Y/n]"), printing its URLs.

Manually, the mechanism is: all host ports, container names, and built image tags in docker-compose-dev.yml are parameterized with environment variables that default to the standard values, so a single checkout needs no configuration. To run a second, fully independent stack (for example from another git worktree), set COMPOSE_PROJECT_NAME, WP1_SUFFIX, and alternate ports for the services you use:

export COMPOSE_PROJECT_NAME=wp1-dev-b
export WP1_SUFFIX=-b            # suffix for container names and image tags
export WP1_REDIS_PORT=9737      # default 9736
export WP1_DB_PORT=6301         # default 6300
export WP1_MINIO_PORT=9002      # default 9000
export WP1_MINIO_CONSOLE_PORT=9003  # default 9001
export WP1_WEB_PORT=5001        # default 5000
export WP1_FRONTEND_PORT=5274   # default 5173
docker compose -f docker-compose-dev.yml up --build

These can also go in the (gitignored) .env file of the worktree, which docker compose reads automatically. The zimfarm profile ports are likewise configurable via WP1_ZIMFARM_DB_PORT (2345), WP1_ZIMFARM_API_PORT (8004) and WP1_ZIMFARM_UI_PORT (8003).

Notes:

  • Each stack gets its own network and volumes (<project>_minio-data), so minio bucket setup runs per stack, and each stack has its own dev database.
  • The backend is referred to by the in-network hostname wp1bot-web-dev (the CLIENT_BACKEND_URL default in wp1/config.py); this keeps working in a suffixed stack via a network alias, no changes needed.
  • dev-web and dev-workers run as WP1_UID:WP1_GID (default 0:0, root). create_worktree.sh sets these to your host user so __pycache__ and log/ files written through the bind mounts aren't root-owned, which would otherwise make git worktree remove fail with "Permission denied". Set them in the main checkout's .env for the same effect there.
  • Stop a worktree's stack (docker compose -f docker-compose-dev.yml down) before removing the worktree: with restart: always, orphaned containers recreate their missing bind-mount paths as root-owned directories.
  • Caveat: the zimfarm UI config (docker/zimfarm/zimfarm_ui_dev/config.json) hardcodes the API URL http://localhost:8004, so a second stack's zimfarm UI won't reach its remapped API without editing that file in the worktree.