(01)Start the full stack
Linux
1docker compose up -d --build2docker compose ps3# RabbitMQ UI: http://localhost:15672 (guest/guest)4# API gateway: http://localhost:3002Postgres + RabbitMQ + gateway + workers with healthchecks and depends_on conditions
docker-compose.yml
Full microservices stack with healthchecks, volumes, and internal service DNS
1version: "3.9"2 3services:4 postgres:5 image: postgres:16-alpine6 environment:7 - POSTGRES_DB=urlshortener8 - POSTGRES_USER=postgres9 - POSTGRES_PASSWORD=postgres10 ports:11 - "5432:5432"12 volumes:13 - pg_data:/var/lib/postgresql/data14 healthcheck:15 test: ["CMD-SHELL", "pg_isready -U postgres"]16 interval: 5s17 timeout: 5s18 retries: 2019 20 rabbitmq:21 image: rabbitmq:3.12-management-alpine22 ports:23 - "5672:5672"24 - "15672:15672"25 environment:26 RABBITMQ_DEFAULT_USER: guest27 RABBITMQ_DEFAULT_PASS: guest28 healthcheck:29 test: ["CMD", "rabbitmq-diagnostics", "ping"]30 interval: 10s31 timeout: 10s32 retries: 1033 34 gateway:35 build: ./gateway36 ports:37 - "3002:3000"38 environment:39 PG_HOST: postgres40 PG_DB: urlshortener41 PG_USER: postgres42 PG_PASSWORD: postgres43 RABBIT_URL: amqp://guest:guest@rabbitmq:567244 BASE_URL: http://localhost:300245 depends_on:46 postgres:47 condition: service_healthy48 rabbitmq:49 condition: service_healthy50 51 cache-worker:52 build: ./cache-worker53 environment:54 RABBIT_URL: amqp://guest:guest@rabbitmq:567255 depends_on:56 rabbitmq:57 condition: service_healthy58 59 analytics-worker:60 build: ./analytics-worker61 environment:62 PG_HOST: postgres63 PG_DB: urlshortener64 PG_USER: postgres65 PG_PASSWORD: postgres66 RABBIT_URL: amqp://guest:guest@rabbitmq:567267 depends_on:68 postgres:69 condition: service_healthy70 rabbitmq:71 condition: service_healthy72 73volumes:74 pg_data:Step 01
1docker compose up -d --build2docker compose ps3# RabbitMQ UI: http://localhost:15672 (guest/guest)4# API gateway: http://localhost:3002