diff --git a/docker-compose.yml b/docker-compose.yml index ee1d415..06c6b92 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: postgres: image: postgres:16-alpine @@ -20,9 +18,27 @@ services: networks: - goplt-network + consul: + image: consul:latest + container_name: goplt-consul + command: consul agent -dev -client=0.0.0.0 + ports: + - "8500:8500" + volumes: + - consul_data:/consul/data + healthcheck: + test: ["CMD-SHELL", "consul members"] + interval: 10s + timeout: 3s + retries: 5 + networks: + - goplt-network + volumes: postgres_data: driver: local + consul_data: + driver: local networks: goplt-network: diff --git a/docs/content/stories/epic2/SUMMARY.md b/docs/content/stories/epic2/SUMMARY.md index 89a7d52..b545232 100644 --- a/docs/content/stories/epic2/SUMMARY.md +++ b/docs/content/stories/epic2/SUMMARY.md @@ -141,9 +141,10 @@ auth: ## Prerequisites 1. **PostgreSQL** running and accessible -2. **Consul** running (for service discovery, optional but recommended) +2. **Consul** running (for service discovery, required for service registry) 3. **Go 1.24+** (or use `nix-shell` for development environment) 4. **NixOS** (optional, for `shell.nix` development environment) +5. **Docker and Docker Compose** (for running PostgreSQL and Consul) ## Building the Services @@ -175,21 +176,35 @@ go build ./cmd/audit-service ## Running the Services -### 1. Start PostgreSQL +### 1. Start PostgreSQL and Consul ```bash -# Using docker-compose (if available) -docker-compose up -d postgres +# Using docker-compose (recommended) +docker-compose up -d postgres consul -# Or start PostgreSQL manually -# Ensure database 'goplt' exists with user 'goplt' and password 'goplt_password' +# Verify containers are running +docker-compose ps + +# Check logs +docker-compose logs postgres +docker-compose logs consul ``` -### 2. Start Consul (Optional) -```bash -# Using docker-compose -docker-compose up -d consul +The docker-compose.yml includes: +- **PostgreSQL**: Available at `localhost:5432` + - Database: `goplt` + - User: `goplt` + - Password: `goplt_password` +- **Consul**: Available at `localhost:8500` + - Running in dev mode + - Web UI: http://localhost:8500/ui (for viewing registered services) + - API: http://localhost:8500/v1 -# Or start Consul manually +### Alternative: Manual Setup +```bash +# Start PostgreSQL manually +# Ensure database 'goplt' exists with user 'goplt' and password 'goplt_password' + +# Start Consul manually consul agent -dev ```