Skip to content

Commit

Permalink
Add docker-compose and dockerfile for api gateway for web
Browse files Browse the repository at this point in the history
  • Loading branch information
blaz-cerpnjak committed Mar 28, 2024
1 parent e379634 commit 5aee5cb
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 1 deletion.
15 changes: 15 additions & 0 deletions API_GatewayWeb/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
2 changes: 1 addition & 1 deletion API_GatewayWeb/HTTP_API/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions API_GatewayWeb/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3.9'

services:
api_gateway_web:
container_name: api_gateway_web
build: .
ports:
- "8080:8080"
restart: always
103 changes: 103 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:

0 comments on commit 5aee5cb

Please sign in to comment.