.PHONY: dev up down build test lint install-deps logs logs-api logs-worker logs-all \ init-db shell-postgres shell-api shell-worker status clean help \ k8s-apply-local k8s-apply-a k8s-down-local k8s-down-a \ swarm-build swarm-deploy swarm-down # Docker Swarm SWARM_STACK ?= handheld # Kubernetes K8S_CHART := k8s/handheld-devices K8S_NAMESPACE ?= handheld-devices K8S_CONTEXT_A ?= # set to your A env context, e.g. gke_project_region_cluster # Default target help: @echo "Handheld Devices - Makefile targets" @echo "" @echo " install-deps Install all deps for local dev (LuaRocks, Deno cache)" @echo " dev, up Start all services (Postgres, Redis, API, worker, frontend)" @echo " down Stop all services" @echo " build Build Docker images" @echo " test Run unit tests (devices-api)" @echo " lint Run Luacheck and Deno check" @echo "" @echo " logs Follow API logs" @echo " logs-worker Follow worker logs" @echo " logs-all Follow all service logs" @echo "" @echo " init-db Run DB migrations (requires services up)" @echo " shell-postgres Open psql in Postgres container" @echo " shell-api Open shell in API container" @echo " shell-worker Open shell in worker container" @echo "" @echo " status Show container status" @echo " clean Stop and remove volumes" @echo "" @echo " k8s-apply-local Helm upgrade/install to local cluster (minikube, kind)" @echo " k8s-apply-a Helm upgrade/install to A env (set K8S_CONTEXT_A)" @echo " k8s-down-local Helm uninstall from local cluster" @echo " k8s-down-a Helm uninstall from A env (set K8S_CONTEXT_A)" @echo "" @echo " swarm-build Build and tag images for Swarm (no build in stack)" @echo " swarm-deploy Deploy stack to Swarm (requires: docker swarm init)" @echo " swarm-down Remove stack from Swarm" install-deps: luarocks install lua-cjson && luarocks install luasocket && luarocks install pgmoon && \ luarocks install redis-lua && luarocks install luaossl && luarocks install busted && \ luarocks install luacheck cd frontend && deno cache main.ts dev up: docker-compose up -d down: docker-compose down build: docker-compose build test: $(MAKE) -C devices-api test lint: luacheck devices-api devices-worker --codes cd frontend && deno check logs: docker-compose logs -f api logs-worker: docker-compose logs -f worker logs-all: docker-compose logs -f init-db: docker-compose exec postgres psql -U devices_user -d handheld_devices \ -f /docker-entrypoint-initdb.d/001_create_devices.sql shell-postgres: docker-compose exec postgres psql -U devices_user -d handheld_devices shell-api: docker-compose exec api sh shell-worker: docker-compose exec worker sh status: docker-compose ps clean: down docker-compose down -v k8s-apply-local: helm upgrade --install handheld-devices $(K8S_CHART) \ -f $(K8S_CHART)/values.yaml \ -f $(K8S_CHART)/values-local.yaml \ -n $(K8S_NAMESPACE) --create-namespace k8s-apply-a: helm upgrade --install handheld-devices $(K8S_CHART) \ -f $(K8S_CHART)/values.yaml \ -f $(K8S_CHART)/values-a.yaml \ -n $(K8S_NAMESPACE) --create-namespace \ $(if $(K8S_CONTEXT_A),--kube-context $(K8S_CONTEXT_A)) k8s-down-local: helm uninstall handheld-devices -n $(K8S_NAMESPACE) --ignore-not-found k8s-down-a: helm uninstall handheld-devices -n $(K8S_NAMESPACE) --ignore-not-found \ $(if $(K8S_CONTEXT_A),--kube-context $(K8S_CONTEXT_A)) swarm-build: docker build -t handheld-devices-api:latest ./devices-api docker build -t handheld-devices-worker:latest ./devices-worker docker build -t handheld-devices-frontend:latest ./frontend swarm-deploy: swarm-build docker stack deploy -c compose.swarm.yml $(SWARM_STACK) swarm-down: docker stack rm $(SWARM_STACK)