Skip to content

DucDat37/ass05

Repository files navigation

Bookstore Microservices

Chạy toàn bộ hệ thống bằng Docker

Yêu cầu

Bước 1: Build và khởi động

Từ thư mục gốc project (bookstore-microservice05):

docker-compose up --build

Lần đầu sẽ build image và chạy 5 service. Để chạy nền (detach):

docker-compose up --build -d

Bước 2: Chạy migration (chỉ lần đầu hoặc khi đổi model)

Mỗi service dùng SQLite riêng, cần tạo bảng một lần:

# Customer
docker-compose exec customer-service python manage.py migrate

# Book
docker-compose exec book-service python manage.py migrate

# Cart
docker-compose exec cart-service python manage.py migrate

# Staff
docker-compose exec staff-service python manage.py migrate

(Gateway không có app với model nên có thể bỏ qua migrate.)

Bước 3: Truy cập

Dịch vụ URL (trình duyệt / API)
API Gateway (Web UI) http://localhost:8000
Customer API http://localhost:8001
Book API http://localhost:8002
Cart API http://localhost:8003
Staff API http://localhost:8004

Trang qua Gateway (port 8000):

Dừng hệ thống:

docker-compose down

Chạy từng service local (không Docker)

  1. Tạo venv, cài dependencies trong từng thư mục: customer-service, book-service, cart-service, staff-service, api-gateway.
  2. Chạy migrate trong từng service có model.
  3. Chạy server trên port khác nhau (ví dụ 8001, 8002, 8003, 8004, 8000).
  4. Trong api-gateway (và các service gọi lẫn nhau), đổi URL sang http://localhost:PORT thay vì http://tên-service:8000 (vì không có Docker network).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors