From 5aee5cb89049934ba40dcf407199722907b8957b Mon Sep 17 00:00:00 2001 From: blaz-cerpnjak Date: Thu, 28 Mar 2024 09:21:51 +0100 Subject: [PATCH] Add docker-compose and dockerfile for api gateway for web --- API_GatewayWeb/Dockerfile | 15 +++++ API_GatewayWeb/HTTP_API/main.go | 2 +- API_GatewayWeb/docker-compose.yml | 9 +++ docker-compose.yml | 103 ++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 API_GatewayWeb/Dockerfile create mode 100644 API_GatewayWeb/docker-compose.yml create mode 100644 docker-compose.yml diff --git a/API_GatewayWeb/Dockerfile b/API_GatewayWeb/Dockerfile new file mode 100644 index 0000000..9d804a5 --- /dev/null +++ b/API_GatewayWeb/Dockerfile @@ -0,0 +1,15 @@ +FROM golang:alpine as builder + +WORKDIR /app + +COPY . . + +RUN go build -o /build + +FROM alpine:latest + +COPY --from=builder /build /app/build + +EXPOSE 8080 + +CMD [ "/app/build" ] \ No newline at end of file diff --git a/API_GatewayWeb/HTTP_API/main.go b/API_GatewayWeb/HTTP_API/main.go index 37e1de8..2e88925 100644 --- a/API_GatewayWeb/HTTP_API/main.go +++ b/API_GatewayWeb/HTTP_API/main.go @@ -29,7 +29,7 @@ func (a *Controller) Start() { a.done = make(chan bool, 0) srv := &http.Server{ - Addr: ":8000", + Addr: ":8080", Handler: engine, ReadTimeout: 20 * time.Second, WriteTimeout: 30 * time.Second, diff --git a/API_GatewayWeb/docker-compose.yml b/API_GatewayWeb/docker-compose.yml new file mode 100644 index 0000000..62a4c57 --- /dev/null +++ b/API_GatewayWeb/docker-compose.yml @@ -0,0 +1,9 @@ +version: '3.9' + +services: + api_gateway_web: + container_name: api_gateway_web + build: . + ports: + - "8080:8080" + restart: always \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..083a43c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,103 @@ +version: '3.1' + +services: + + ### User Management API + mongo_db_users: + image: mongo:7.0.6 + volumes: + - mongo_data_users:/data/mongo + restart: unless-stopped + networks: + - native + + user_management_api: + container_name: users_management_api + build: + context: UserManagementAPI + dockerfile: Dockerfile + restart: always + environment: + MONGO_DB_URI: mongodb://mongo_db_users:27017/users_db + expose: + - 8080 + depends_on: + - mongo_db_users + networks: + - native + + ### Restaurant Management API + mongo_db_restaurants: + image: mongo:7.0.6 + volumes: + - mongo_data_restaurants:/data/mongo + restart: unless-stopped + networks: + - native + + restaurant_management_api: + container_name: restaurant_management_api + build: + context: RestaurantManagementAPI + dockerfile: ./src/main/docker/Dockerfile.jvm + restart: always + environment: + MONGO_DB_URI: mongodb://mongo_db_restaurants:27017/restaurant_db + expose: + - 8080 + depends_on: + - mongo_db_restaurants + networks: + - native + + ### Order Processing API + mongo_db_orders: + image: mongo:7.0.6 + volumes: + - mongo_data_orders:/data/mongo + restart: unless-stopped + networks: + - native + + order_processing_api: + container_name: order_processing_grpc_api + build: + context: OrderProcessingAPI + dockerfile: ./src/main/docker/Dockerfile.jvm + restart: always + environment: + MONGO_DB_URI: mongodb://mongo_db_orders:27017/orders_db + RABBITMQ_HOST: rabbitmq_container + expose: + - 8080 + - 9000 + depends_on: + - mongo_db_orders + networks: + - native + + web_api_gateway: + build: + context: API_GatewayWEB + dockerfile: Dockerfile + restart: always + environment: + USERS_API: http://users_management_api:8080/api/v1 + RESTAURANTS_API: http://restaurant_management_api:8080 + ORDERS_GRPC_API: order_processing_grpc_api:9000 + expose: + - 8080 + ports: + - "8080:8080" + networks: + - native + +networks: + native: + name: native-network + driver: bridge + +volumes: + mongo_data_users: + mongo_data_restaurants: + mongo_data_orders: \ No newline at end of file