feat(docker): Add Consul to docker-compose and update documentation

- Add Consul service to docker-compose.yml
  - Running in dev mode on port 8500
  - Health checks configured
  - Persistent volume for data
  - Web UI available at http://localhost:8500/ui

- Update SUMMARY.md
  - Document Consul setup in docker-compose
  - Add Consul verification steps
  - Update prerequisites to include Docker Compose
  - Add note about Consul Web UI

- Remove obsolete version field from docker-compose.yml
This commit is contained in:
2025-11-06 20:08:37 +01:00
parent cb28a120ed
commit 3ac8983e98
2 changed files with 44 additions and 13 deletions

View File

@@ -1,5 +1,3 @@
version: '3.8'
services: services:
postgres: postgres:
image: postgres:16-alpine image: postgres:16-alpine
@@ -20,9 +18,27 @@ services:
networks: networks:
- goplt-network - 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: volumes:
postgres_data: postgres_data:
driver: local driver: local
consul_data:
driver: local
networks: networks:
goplt-network: goplt-network:

View File

@@ -141,9 +141,10 @@ auth:
## Prerequisites ## Prerequisites
1. **PostgreSQL** running and accessible 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) 3. **Go 1.24+** (or use `nix-shell` for development environment)
4. **NixOS** (optional, for `shell.nix` development environment) 4. **NixOS** (optional, for `shell.nix` development environment)
5. **Docker and Docker Compose** (for running PostgreSQL and Consul)
## Building the Services ## Building the Services
@@ -175,21 +176,35 @@ go build ./cmd/audit-service
## Running the Services ## Running the Services
### 1. Start PostgreSQL ### 1. Start PostgreSQL and Consul
```bash ```bash
# Using docker-compose (if available) # Using docker-compose (recommended)
docker-compose up -d postgres docker-compose up -d postgres consul
# Or start PostgreSQL manually # Verify containers are running
# Ensure database 'goplt' exists with user 'goplt' and password 'goplt_password' docker-compose ps
# Check logs
docker-compose logs postgres
docker-compose logs consul
``` ```
### 2. Start Consul (Optional) The docker-compose.yml includes:
```bash - **PostgreSQL**: Available at `localhost:5432`
# Using docker-compose - Database: `goplt`
docker-compose up -d consul - 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 consul agent -dev
``` ```