# Micro-Demo — Simple Microservices with Docker Compose
This project demonstrates how to build **two microservices** (Account & Inventory), **containerize** them with Docker, and run them together behind a simple **NGINX gateway** using `docker-compose`.
---
## 📂 Project Structuremicro-demo/ ├─ account/ │ ├─ app.py │ └─ Dockerfile ├─ inventory/ │ ├─ app.py │ └─ Dockerfile ├─ gateway/ │ └─ nginx.conf └─ docker-compose.yml
---
## 🚀 Quick Start
### 1. Build the images
```
docker-compose build
docker-compose up -d
curl http://localhost:8080/ # → gateway ok
curl http://localhost:8080/account/api/v1/users # → list of users
curl http://localhost:8080/inventory/api/v1/products # → list of products
-
View running containers:
docker ps -
Follow logs:
docker-compose logs -f -
Stop services:
docker-compose down -
Stop & remove everything (containers, images, networks):
docker-compose down --rmi local -
Rebuild after code changes:
docker-compose build docker-compose up -d
-
Account Service → Flask app exposes
/api/v1/users. -
Inventory Service → Flask app exposes
/api/v1/products. -
NGINX Gateway → Acts as an API Gateway:
/account/*→ routes to account service/inventory/*→ routes to inventory service
-
docker-compose → Orchestrates all containers on a shared network.
-
Clients only talk to gateway (port 8080), which forwards requests to services.
-
Port 8080 already in use → change the port in
docker-compose.yml("8081:80"). -
Gateway returns 502 → check if
accountandinventorycontainers are running (docker ps). -
Code changes not reflected → rebuild containers:
docker-compose build docker-compose up -d
To remove everything:
docker-compose down --rmi local