Skip to main content

gws rebuild

Rebuild and redeploy one service in the active deployment, leaving every other service running. The watch orchestrator calls this automatically when it detects a Dockerfile or source change that requires a fresh image; you can call it directly when you want to force a rebuild without going through gws down && gws up.

Uses GetWebstack's embedded Kubernetes client (no kubectl) and the bundled image-build manager (k3d / minikube / docker depending on the cluster).

Usage

gws rebuild <service> [options]
ArgumentDescription
serviceName of the service in gws.json to rebuild.
FlagDescription
-w, --worktree <name>Worktree to target (defaults to active worktree).

Auth: requires an active deployment for the target project / worktree — gws up must have been run for it. gws rebuild rolls a new image into an existing Deployment; it does not create one. If -w points at a worktree that isn't currently deployed, the command will fail with No active deployment with deployment ID found.

Behaviour

  1. Resolves the project + worktree.
  2. Loads the deployment record to find the cluster (kubeconfigPath, kubeContext, registryPort).
  3. Looks up the service in gws.json — fails if the name doesn't exist.
  4. Picks an ImageBuildManager strategy based on cluster type and registry mode.
  5. Builds the new image and pushes it to the cluster's registry.
  6. Patches the existing Deployment to roll the new image without touching anything else.

If you've changed gws.json itself (added a new service, changed dependencies, …), use gws config import + gws up instead — gws rebuild only rolls a single service's image.

Examples

# Rebuild the api service
gws rebuild api

# Rebuild on a worktree
gws rebuild api -w feature-payments

# Force a rebuild after a manual code edit, without changing gws.json
gws rebuild worker

See also