diff --git a/Makefile b/Makefile index 3790651..ab584d5 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ BACKEND_DIR := backend BUILD_DIR := bin MAIN_PATH := ./cmd/api -.PHONY: all build run test test-race fmt vet clean help db db-stop db-logs db-psql db-reset migrate migrate-down migrate-status +.PHONY: all build run dev test test-race fmt vet clean help db db-stop db-logs db-psql db-reset migrate migrate-down migrate-status # Default target when running only 'make' all: help @@ -28,6 +28,10 @@ run: ## Run the API (go run, no binary left behind) @echo "==> Running the API..." cd $(BACKEND_DIR) && go run $(MAIN_PATH) +dev: ## Start everything in Docker (PostgreSQL + API) + @echo "==> Starting the full stack in Docker..." + docker compose up --build + test: ## Run all backend tests @echo "==> Running tests..." cd $(BACKEND_DIR) && go test ./... diff --git a/compose.yaml b/compose.yaml index 4636c43..cdbdf16 100644 --- a/compose.yaml +++ b/compose.yaml @@ -23,5 +23,22 @@ services: timeout: 5s retries: 5 + api: + # Built from backend/Dockerfile (the build context is the backend/ folder). + build: ./backend + container_name: aktenlens-api + restart: unless-stopped + environment: + # Inside the Compose network the database host is the service name + # "postgres" and the port is the container port (5432), not the + # 127.0.0.1:5433 used from your own machine. + DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable + ports: + # Bound to 127.0.0.1 so only this machine can reach the API. + - "127.0.0.1:8080:8080" + depends_on: + postgres: + condition: service_healthy + volumes: aktenlens-postgres-data: