chore: update docker-compose, make, tmt config
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
41eacaf97d
commit
f53b7f7d8a
11 changed files with 118 additions and 39 deletions
|
|
@ -1,3 +1,4 @@
|
|||
# DEPRECATED: Use docker-compose.prod.yml at repo root. See README.md.
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ services:
|
|||
- COOKIE_SECURE=true
|
||||
- COOKIE_SAME_SITE=strict
|
||||
- COOKIE_HTTP_ONLY=true
|
||||
- CORS_ALLOWED_ORIGINS=${CORS_ORIGINS:-http://localhost}
|
||||
- CORS_ALLOWED_ORIGINS=${CORS_ORIGINS:-http://veza.fr}
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@ services:
|
|||
image: redis:7-alpine
|
||||
container_name: veza-redis-test
|
||||
ports:
|
||||
- "6380:6379"
|
||||
# Use tmpfs for faster tests and automatic cleanup
|
||||
- "6380:6379" # Host 6380 évite conflit avec dev (16379)
|
||||
tmpfs:
|
||||
- /data
|
||||
networks:
|
||||
|
|
@ -40,6 +39,24 @@ services:
|
|||
retries: 5
|
||||
start_period: 5s
|
||||
|
||||
rabbitmq-test:
|
||||
image: rabbitmq:3-management-alpine
|
||||
container_name: veza-rabbitmq-test
|
||||
environment:
|
||||
RABBITMQ_DEFAULT_USER: veza_test
|
||||
RABBITMQ_DEFAULT_PASS: veza_test
|
||||
ports:
|
||||
- "5673:5672" # AMQP (évite conflit avec dev 15672)
|
||||
- "15673:15672" # Management UI
|
||||
networks:
|
||||
- veza-test-network
|
||||
healthcheck:
|
||||
test: rabbitmq-diagnostics -q ping
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 20s
|
||||
|
||||
networks:
|
||||
veza-test-network:
|
||||
driver: bridge
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
services:
|
||||
# PostgreSQL - Primary Database
|
||||
# Limit: 256MB RAM. Sufficient for local dev schemas.
|
||||
# Port 15432 avoids conflict with other projects using default 5432
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: veza_postgres
|
||||
|
|
@ -10,7 +11,7 @@ services:
|
|||
POSTGRES_PASSWORD: password
|
||||
POSTGRES_DB: veza
|
||||
ports:
|
||||
- "5432:5432"
|
||||
- "${PORT_POSTGRES:-15432}:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
|
|
@ -18,6 +19,8 @@ services:
|
|||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- veza-net
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
|
|
@ -27,13 +30,13 @@ services:
|
|||
memory: 128M
|
||||
|
||||
# Redis - Cache & PubSub
|
||||
# Limit: 64MB RAM.
|
||||
# Limit: 64MB RAM. Port 16379 avoids conflict with other projects (default 6379)
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: veza_redis
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "6379:6379"
|
||||
- "${PORT_REDIS:-16379}:6379"
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
healthcheck:
|
||||
|
|
@ -41,6 +44,8 @@ services:
|
|||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
networks:
|
||||
- veza-net
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
|
|
@ -50,7 +55,7 @@ services:
|
|||
memory: 32M
|
||||
|
||||
# RabbitMQ - Message Broker
|
||||
# Limit: 256MB RAM. Uses Erlang, can be memory hungry. Alpine helps.
|
||||
# Limit: 256MB RAM. Host 15672->AMQP(5672), 25672->Management(15672)
|
||||
rabbitmq:
|
||||
image: rabbitmq:3-management-alpine
|
||||
container_name: veza_rabbitmq
|
||||
|
|
@ -59,15 +64,18 @@ services:
|
|||
RABBITMQ_DEFAULT_USER: veza
|
||||
RABBITMQ_DEFAULT_PASS: password
|
||||
ports:
|
||||
- "5672:5672" # AMQP
|
||||
- "15672:15672" # Management UI
|
||||
- "${PORT_RABBITMQ_AMQP:-15672}:5672" # AMQP (messaging)
|
||||
- "${PORT_RABBITMQ_MGMT:-25672}:15672" # Management UI
|
||||
volumes:
|
||||
- rabbitmq_data:/var/lib/rabbitmq
|
||||
healthcheck:
|
||||
test: rabbitmq-diagnostics -q ping
|
||||
interval: 10s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
start_period: 40s
|
||||
networks:
|
||||
- veza-net
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
|
|
@ -75,8 +83,8 @@ services:
|
|||
memory: 512M
|
||||
reservations:
|
||||
memory: 256M
|
||||
# Backend API (si nécessaire pour développement local)
|
||||
# Décommenter et configurer selon vos besoins
|
||||
|
||||
# Backend API (Docker dev)
|
||||
backend-api:
|
||||
build:
|
||||
context: ./veza-backend-api
|
||||
|
|
@ -87,27 +95,34 @@ services:
|
|||
- REDIS_URL=redis://redis:6379
|
||||
- JWT_SECRET=dev-secret-key-minimum-32-characters-long
|
||||
- COOKIE_SECURE=false # false en dev local
|
||||
- COOKIE_SAME_SITE=lax # lax pour permettre localhost
|
||||
- COOKIE_SAME_SITE=lax
|
||||
- COOKIE_DOMAIN=
|
||||
- COOKIE_HTTP_ONLY=true
|
||||
- COOKIE_PATH=/
|
||||
- CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
|
||||
- CORS_ALLOWED_ORIGINS=http://veza.fr:3000,http://veza.fr:5173
|
||||
- RABBITMQ_URL=amqp://veza:password@rabbitmq:5672/
|
||||
ports:
|
||||
- "8080:8080"
|
||||
- "${PORT_BACKEND:-18080}:8080"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck: # Ajout d'une healthcheck pour le backend API
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/api/v1/health"] # Assurez-vous que cet endpoint existe
|
||||
rabbitmq:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- veza-net
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/api/v1/health"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
rabbitmq_data:
|
||||
|
||||
networks:
|
||||
veza-net:
|
||||
driver: bridge
|
||||
|
|
|
|||
|
|
@ -26,12 +26,19 @@ SERVICE_DIR_stream-server := veza-stream-server
|
|||
SERVICE_DIR_web := apps/web
|
||||
SERVICE_DIR_haproxy :=
|
||||
|
||||
# --- Ports (override with PORT_<SERVICE>=... from .env)
|
||||
PORT_backend-api ?= 8080
|
||||
# --- Ports (override with PORT_* from .env)
|
||||
# Defaults use 18xxx range to avoid conflicts with other projects on same machine
|
||||
PORT_backend-api ?= 18080
|
||||
PORT_chat-server ?= 3000
|
||||
PORT_stream-server ?= 3001
|
||||
PORT_web ?= 5173
|
||||
PORT_haproxy ?= 80
|
||||
# Infra (docker-compose dev)
|
||||
PORT_POSTGRES ?= 15432
|
||||
PORT_REDIS ?= 16379
|
||||
PORT_RABBITMQ_AMQP ?= 15672
|
||||
PORT_RABBITMQ_MGMT ?= 25672
|
||||
PORT_BACKEND ?= 18080
|
||||
|
||||
# Legacy names for backward compatibility
|
||||
PORT_GO ?= $(PORT_backend-api)
|
||||
|
|
@ -40,16 +47,23 @@ PORT_STREAM ?= $(PORT_stream-server)
|
|||
PORT_WEB ?= $(PORT_web)
|
||||
PORT_HAPROXY ?= $(PORT_haproxy)
|
||||
|
||||
# --- Domain (single source of truth — override via APP_DOMAIN=... env) ---
|
||||
APP_DOMAIN ?= veza.fr
|
||||
|
||||
# --- Database & Infra ---
|
||||
# Host ports when using docker-compose (override in .env if needed)
|
||||
DB_USER ?= veza
|
||||
DB_PASS ?= password
|
||||
DB_NAME ?= veza
|
||||
DB_HOST ?= localhost
|
||||
DB_PORT ?= 5432
|
||||
DB_HOST ?= $(APP_DOMAIN)
|
||||
DB_PORT ?= $(PORT_POSTGRES)
|
||||
|
||||
# Connection strings for backend running on host connecting to Docker infra
|
||||
# In Docker: backend uses postgres:5432, redis:6379, rabbitmq:5672 (internal)
|
||||
# On host: use mapped ports from env (15432, 16379, 15672)
|
||||
DATABASE_URL = postgres://$(DB_USER):$(DB_PASS)@$(DB_HOST):$(DB_PORT)/$(DB_NAME)?sslmode=disable
|
||||
REDIS_URL = redis://localhost:6379
|
||||
AMQP_URL = amqp://$(DB_USER):$(DB_PASS)@localhost:5672
|
||||
REDIS_URL = redis://$(APP_DOMAIN):$(PORT_REDIS)
|
||||
AMQP_URL = amqp://$(DB_USER):$(DB_PASS)@$(APP_DOMAIN):$(PORT_RABBITMQ_AMQP)/
|
||||
|
||||
# --- Incus ---
|
||||
DEPLOY_TARGET ?= docker
|
||||
|
|
|
|||
22
make/dev.mk
22
make/dev.mk
|
|
@ -1,15 +1,25 @@
|
|||
# ==============================================================================
|
||||
# DEVELOPMENT (local run with optional hot reload)
|
||||
# ==============================================================================
|
||||
# dev: Backend API (Docker from infra-up) + Web only. Chat/Stream Rust servers
|
||||
# are skipped until veza-common is fixed. Use dev-full to start everything.
|
||||
# ==============================================================================
|
||||
|
||||
.PHONY: dev dev-backend dev-web dev-backend-api dev-chat-server dev-stream-server
|
||||
.PHONY: dev dev-full dev-backend dev-web dev-backend-api dev-chat-server dev-stream-server
|
||||
.PHONY: stop-local-services start-local-service stop-local-service
|
||||
|
||||
dev: check-ports infra-up ## [HIGH] Start Everything (Detects Hot Reload tools)
|
||||
@$(ECHO_CMD) "${BOLD}${PURPLE}🚀 STARTING HYBRID DEV ENVIRONMENT${NC}"
|
||||
@$(ECHO_CMD) " Go: http://localhost:$(PORT_backend-api)"
|
||||
@$(ECHO_CMD) " Chat: http://localhost:$(PORT_chat-server)"
|
||||
@$(ECHO_CMD) " Web: http://localhost:$(PORT_web)"
|
||||
dev: check-ports infra-up ## [HIGH] Start Backend (Docker) + Web only (no Chat/Stream)
|
||||
@$(ECHO_CMD) "${BOLD}${PURPLE}🚀 STARTING DEV (Backend + Web)${NC}"
|
||||
@$(ECHO_CMD) " Backend: http://$(APP_DOMAIN):$(PORT_backend-api) (Docker)"
|
||||
@$(ECHO_CMD) " Web: http://$(APP_DOMAIN):$(PORT_web)"
|
||||
@$(ECHO_CMD) "${YELLOW}Hit Ctrl+C to stop.${NC}"
|
||||
@cd $(ROOT)/$(SERVICE_DIR_web) && npm run dev
|
||||
|
||||
dev-full: check-ports infra-up ## [HIGH] Start Everything inc. Chat + Stream (Rust)
|
||||
@$(ECHO_CMD) "${BOLD}${PURPLE}🚀 STARTING HYBRID DEV ENVIRONMENT (full)${NC}"
|
||||
@$(ECHO_CMD) " Go: http://$(APP_DOMAIN):$(PORT_backend-api)"
|
||||
@$(ECHO_CMD) " Chat: http://$(APP_DOMAIN):$(PORT_chat-server)"
|
||||
@$(ECHO_CMD) " Web: http://$(APP_DOMAIN):$(PORT_web)"
|
||||
@$(ECHO_CMD) "${YELLOW}Hit Ctrl+C to stop all.${NC}"
|
||||
@(trap 'kill 0' SIGINT; \
|
||||
if command -v air >/dev/null; then \
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ help: ## [HIGH] Show this dashboard
|
|||
@$(ECHO_CMD) "${BOLD}INFRASTRUCTURE:${NC}"
|
||||
@printf " ${CYAN}%-15s${NC} %s\n" "Postgres" "$(DATABASE_URL)"
|
||||
@printf " ${CYAN}%-15s${NC} %s\n" "Redis" "$(REDIS_URL)"
|
||||
@printf " ${CYAN}%-15s${NC} %s\n" "RabbitMQ" "UI: http://localhost:15672 (veza/password)"
|
||||
@printf " ${CYAN}%-15s${NC} %s\n" "RabbitMQ" "UI: http://$(APP_DOMAIN):15672 (veza/password)"
|
||||
@$(ECHO_CMD) ""
|
||||
@$(ECHO_CMD) "${BOLD}${GREEN}HIGH LEVEL:${NC}"
|
||||
@grep -h -E '^[a-zA-Z0-9_-]+:.*?## \[HIGH\] .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " ${YELLOW}%-25s${NC} %s\n", $$1, $$2}'
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ deploy-docker: build-all ## [HIGH] Deploy all services with Docker + HAProxy
|
|||
@$(ECHO_CMD) "${BOLD}${BLUE}🐳 Deploying with Docker...${NC}"
|
||||
@docker compose -f $(COMPOSE_PROD) up -d --build
|
||||
@$(MAKE) -s wait-for-services
|
||||
@$(ECHO_CMD) "${GREEN}✅ Deployment complete! Access via http://localhost:$(PORT_haproxy)${NC}"
|
||||
@$(ECHO_CMD) "${GREEN}✅ Deployment complete! Access via http://$(APP_DOMAIN):$(PORT_haproxy)${NC}"
|
||||
|
||||
deploy-incus: build-all-native ## [HIGH] Deploy all services with Incus containers (native, no Docker)
|
||||
@$(ECHO_CMD) "${BOLD}${BLUE}📦 Deploying with Incus (native)...${NC}"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# INFRASTRUCTURE (Docker: Postgres, Redis, RabbitMQ)
|
||||
# ==============================================================================
|
||||
|
||||
.PHONY: infra-up infra-down wait-for-infra wait-for-services db-shell redis-shell db-migrate
|
||||
.PHONY: infra-up infra-down wait-for-infra wait-for-services db-shell redis-shell rabbitmq-shell db-migrate
|
||||
|
||||
infra-up: ## [MID] Start Docker Infra (with health checks)
|
||||
@$(ECHO_CMD) "${BLUE}🐳 Starting Infrastructure...${NC}"
|
||||
|
|
@ -13,10 +13,11 @@ infra-down: ## [MID] Stop Docker Infra
|
|||
@$(ECHO_CMD) "${BLUE}🛑 Stopping Infrastructure...${NC}"
|
||||
@docker compose -f $(COMPOSE_FILE) down
|
||||
|
||||
wait-for-infra: ## [LOW] Wait for infrastructure to be ready
|
||||
wait-for-infra: ## [LOW] Wait for infrastructure to be ready (Postgres, Redis, RabbitMQ)
|
||||
@printf "${BLUE}⏳ Waiting for services...${NC}"
|
||||
@until docker compose -f $(COMPOSE_FILE) exec -T postgres pg_isready -U $(DB_USER) > /dev/null 2>&1; do printf "."; sleep 1; done
|
||||
@until docker compose -f $(COMPOSE_FILE) exec -T redis redis-cli ping > /dev/null 2>&1; do printf "."; sleep 1; done
|
||||
@until docker compose -f $(COMPOSE_FILE) exec -T rabbitmq rabbitmq-diagnostics -q ping > /dev/null 2>&1; do printf "."; sleep 1; done
|
||||
@$(ECHO_CMD) " ${GREEN}OK${NC}"
|
||||
|
||||
wait-for-services: ## [LOW] Wait for all application services
|
||||
|
|
@ -34,6 +35,9 @@ db-shell: ## [MID] Connect to Postgres shell
|
|||
redis-shell: ## [MID] Connect to Redis shell
|
||||
@docker compose -f $(COMPOSE_FILE) exec redis redis-cli
|
||||
|
||||
rabbitmq-shell: ## [MID] Connect to RabbitMQ management (browser: http://$(APP_DOMAIN):$(PORT_RABBITMQ_MGMT))
|
||||
@$(ECHO_CMD) "${BLUE}RabbitMQ Management: http://$(APP_DOMAIN):$(PORT_RABBITMQ_MGMT) (user: $(DB_USER), pass: $(DB_PASS))${NC}"
|
||||
|
||||
db-migrate: infra-up ## [MID] Run all database migrations
|
||||
@$(ECHO_CMD) "${BLUE}🔄 Running Migrations...${NC}"
|
||||
@$(ECHO_CMD) " -> [Go] Migrating..."
|
||||
|
|
|
|||
19
make/test.mk
19
make/test.mk
|
|
@ -5,10 +5,19 @@
|
|||
.PHONY: test test-tmt lint fmt status test-web test-backend-api test-chat-server test-stream-server
|
||||
.PHONY: lint-web lint-backend-api lint-chat-server lint-stream-server
|
||||
|
||||
# Env vars for backend tests (align with docker-compose ports: Redis 16379, RabbitMQ 15672)
|
||||
TEST_REDIS_ADDR ?= localhost:$(PORT_REDIS)
|
||||
TEST_REDIS_URL ?= redis://localhost:$(PORT_REDIS)/15
|
||||
TEST_RABBITMQ_URL ?= amqp://$(DB_USER):$(DB_PASS)@localhost:$(PORT_RABBITMQ_AMQP)/
|
||||
|
||||
test: infra-up ## [MID] Run All Tests (Fastest strategy)
|
||||
@$(ECHO_CMD) "${BLUE}🧪 Running Tests...${NC}"
|
||||
@$(ECHO_CMD) " [Go] Unit Tests..."
|
||||
@(cd $(ROOT)/$(SERVICE_DIR_backend-api) && go test ./... -short)
|
||||
@(cd $(ROOT)/$(SERVICE_DIR_backend-api) && \
|
||||
REDIS_ADDR=$(TEST_REDIS_ADDR) \
|
||||
REDIS_TEST_URL=$(TEST_REDIS_URL) \
|
||||
RABBITMQ_URL=$(TEST_RABBITMQ_URL) \
|
||||
go test ./... -short)
|
||||
@$(ECHO_CMD) " [Rust] Unit Tests..."
|
||||
@(cd $(ROOT)/$(SERVICE_DIR_chat-server) && cargo test --lib -q)
|
||||
@(cd $(ROOT)/$(SERVICE_DIR_stream-server) && cargo test --lib -q)
|
||||
|
|
@ -25,9 +34,13 @@ test-web: ## [MID] Run Web tests only
|
|||
@$(ECHO_CMD) "${BLUE}🧪 Running Web tests...${NC}"
|
||||
@(cd $(ROOT)/$(SERVICE_DIR_web) && npm run test -- --run)
|
||||
|
||||
test-backend-api: ## [MID] Run Go backend tests only
|
||||
test-backend-api: infra-up ## [MID] Run Go backend tests only
|
||||
@$(ECHO_CMD) "${BLUE}🧪 Running Backend API tests...${NC}"
|
||||
@(cd $(ROOT)/$(SERVICE_DIR_backend-api) && go test ./... -short)
|
||||
@(cd $(ROOT)/$(SERVICE_DIR_backend-api) && \
|
||||
REDIS_ADDR=$(TEST_REDIS_ADDR) \
|
||||
REDIS_TEST_URL=$(TEST_REDIS_URL) \
|
||||
RABBITMQ_URL=$(TEST_RABBITMQ_URL) \
|
||||
go test ./... -short)
|
||||
|
||||
test-chat-server: ## [MID] Run Chat server tests only
|
||||
@$(ECHO_CMD) "${BLUE}🧪 Running Chat server tests...${NC}"
|
||||
|
|
|
|||
|
|
@ -6,6 +6,11 @@ duration: 10m
|
|||
require:
|
||||
- npm
|
||||
|
||||
/unit:
|
||||
summary: Unit Tests (Vitest)
|
||||
test: ./unit.sh
|
||||
tier: 1
|
||||
|
||||
/build:
|
||||
summary: Build Test
|
||||
test: ./build.sh
|
||||
|
|
|
|||
Loading…
Reference in a new issue