All checks were successful
secrets-guard / encrypted (pull_request) Successful in 5s
shell-lint / shellcheck (pull_request) Successful in 7s
PR build (required check) / changes (pull_request) Successful in 19s
PR build (required check) / build-backend (pull_request) Has been skipped
PR build (required check) / build-frontend (pull_request) Has been skipped
PR build (required check) / validate-observability (pull_request) Has been skipped
PR build (required check) / gate (pull_request) Successful in 1s
Sync infra to hosts / sync-beta (push) Has been skipped
Sync infra to hosts / sync-prod (push) Has been skipped
Sync infra to hosts / sync-centralis (push) Has been skipped
secrets-guard / encrypted (push) Successful in 6s
Sync infra to hosts / sync-dev (push) Successful in 12s
shell-lint / shellcheck (push) Successful in 8s
A fresh checkout had no working path to the stack locally. Neither compose file carries a `build:` for backend or frontend -- each ships as its own registry image -- so with no image present `make dev-up` fell through to pulling the `:local` tag, which nothing publishes, and failed with 403 against a registry a laptop has no login for. `install` builds both images from backend/Dockerfile and frontend/Dockerfile under exactly the tag the compose files default to; `up` verifies they exist and says what to run instead of retrying the pull. Image names are read back from `docker compose config --images` rather than restated here, so an org rename cannot leave this file building a tag nothing runs. infra's dev-up/dev-down now set COMPOSE_PROJECT_NAME=thermograph-dev, which matches deploy/deploy-dev.sh and what the root CLAUDE.md already described; a local run previously landed in the prod-shaped `thermograph` project. Drop dev-up's `--build`, a no-op since the Dockerfiles moved out of infra, and correct the comment claiming a 0.0.0.0 default -- the overlay has published on loopback since dev moved to a public VPS.
81 lines
3.9 KiB
Makefile
81 lines
3.9 KiB
Makefile
# Laptop-local entry point: build the two service images, run the dev stack.
|
|
#
|
|
# No fleet host uses this file. dev, beta and prod all deploy through
|
|
# infra/deploy/deploy.sh, which pulls registry images by their sha-<12hex> tag.
|
|
# A laptop has no registry login, so `install` BUILDS both images under the
|
|
# `:local` tag that infra/docker-compose.yml already falls back to
|
|
# (BACKEND_IMAGE_TAG / FRONTEND_IMAGE_TAG default to `local`). Without that
|
|
# build step `up` would try to PULL `:local`, which is published nowhere and
|
|
# fails with a 403 -- so `up` checks for the images first and says what to run.
|
|
#
|
|
# This wraps infra's own compose targets; `make -C infra dev-up` remains
|
|
# equivalent to `make up` here, same project name, same overlay, same stack.
|
|
|
|
SHELL := /bin/bash
|
|
|
|
# Keeps this stack's volumes off the prod-shaped `thermograph` project that
|
|
# infra/docker-compose.yml pins by default (the env var always wins over the
|
|
# file's `name:` key).
|
|
COMPOSE_PROJECT_NAME ?= thermograph-dev
|
|
POSTGRES_PASSWORD ?= thermograph-dev
|
|
# The daemon refuses to start without this, and the backend answers 404 on the
|
|
# whole /internal/* surface while it is unset -- both fail closed. A throwaway
|
|
# value is all a laptop needs; nothing outside this stack accepts it.
|
|
THERMOGRAPH_INTERNAL_TOKEN ?= dev-token
|
|
export COMPOSE_PROJECT_NAME POSTGRES_PASSWORD THERMOGRAPH_INTERNAL_TOKEN
|
|
|
|
# The dev overlay publishes backend on $DEV_BIND_ADDR, default loopback. Set
|
|
# DEV_BIND_ADDR=0.0.0.0 to reach it from phones on your own Wi-Fi -- safe on a
|
|
# laptop LAN, never on a fleet host (see infra/docker-compose.dev.yml).
|
|
COMPOSE := docker compose -f infra/docker-compose.yml -f infra/docker-compose.dev.yml
|
|
|
|
# Ask compose what it will run rather than restating the image names here --
|
|
# REGISTRY_HOST / *_IMAGE_PATH / *_IMAGE_TAG all have defaults in
|
|
# infra/docker-compose.yml, and a second copy of them in this file is a rename
|
|
# away from silently building a tag nothing runs. `--images <service>` also
|
|
# lists that service's dependencies, hence the per-service filter. Override by
|
|
# passing BACKEND_IMAGE=... / FRONTEND_IMAGE=... if you need a one-off tag.
|
|
# POSTGRES_PASSWORD is inlined because `config` refuses to interpolate without
|
|
# it, and $(shell) does not see make's `export` directives.
|
|
CONFIG_ENV := POSTGRES_PASSWORD=$(POSTGRES_PASSWORD)
|
|
ifndef BACKEND_IMAGE
|
|
BACKEND_IMAGE := $(shell $(CONFIG_ENV) $(COMPOSE) config --images backend 2>/dev/null | grep -m1 '/backend:')
|
|
endif
|
|
ifndef FRONTEND_IMAGE
|
|
FRONTEND_IMAGE := $(shell $(CONFIG_ENV) $(COMPOSE) config --images frontend 2>/dev/null | grep -m1 '/frontend:')
|
|
endif
|
|
|
|
.DEFAULT_GOAL := help
|
|
.PHONY: help install up down logs ps check-images-resolved
|
|
|
|
help: ## List targets
|
|
@grep -hE '^[a-z-]+:.*?## ' $(MAKEFILE_LIST) \
|
|
| awk -F':.*?## ' '{printf " \033[36m%-8s\033[0m %s\n", $$1, $$2}'
|
|
|
|
# Empty means `docker compose config` itself failed -- a broken compose file or
|
|
# no docker at all. Fail here rather than running `docker build -t ""`.
|
|
check-images-resolved:
|
|
@[[ -n "$(BACKEND_IMAGE)" && -n "$(FRONTEND_IMAGE)" ]] || { \
|
|
echo "could not resolve image names from infra/docker-compose.yml;" >&2; \
|
|
echo "check 'docker compose -f infra/docker-compose.yml config'" >&2; exit 1; }
|
|
|
|
install: check-images-resolved ## Build backend + frontend images as :local (run once before `up`)
|
|
docker build -t $(BACKEND_IMAGE) backend
|
|
docker build -t $(FRONTEND_IMAGE) frontend
|
|
|
|
up: check-images-resolved ## Start the local dev stack, uncapped, backend on 127.0.0.1:8137
|
|
@for img in $(BACKEND_IMAGE) $(FRONTEND_IMAGE); do \
|
|
docker image inspect "$$img" >/dev/null 2>&1 || { \
|
|
echo "missing image $$img -- run 'make install' first" >&2; exit 1; }; \
|
|
done
|
|
$(COMPOSE) up -d
|
|
@echo "backend: http://$${DEV_BIND_ADDR:-127.0.0.1}:8137"
|
|
|
|
down: ## Stop the stack (named volumes persist)
|
|
$(COMPOSE) down
|
|
|
|
logs: ## Follow the stack's logs (SERVICE=backend to narrow)
|
|
$(COMPOSE) logs -f $(SERVICE)
|
|
|
|
ps: ## Show the stack's containers
|
|
$(COMPOSE) ps
|