Skip to content

Commit 95102b5

Browse files
committed
feat: add config for run gRPC
1 parent 073490d commit 95102b5

File tree

5 files changed

+46
-12
lines changed

5 files changed

+46
-12
lines changed

docker-compose.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,40 @@ services:
4646
networks:
4747
- spring-cloud-network
4848

49-
identity-service:
50-
build: ./identity-service
51-
container_name: identity-service
49+
protobuf:
50+
build: ./protobuf
51+
container_name: protobuf
52+
restart: always
53+
networks:
54+
- spring-cloud-network
55+
56+
user-service:
57+
build: ./user-service
58+
container_name: user-service
5259
ports:
53-
- "18081:8081"
60+
- "18080:8080" # HTTP
61+
- "19090:19090" # gRPC
5462
restart: always
5563
environment:
5664
- SPRING_DATASOURCE_URL
57-
- GOOGLE_CLIENT_ID
58-
- GOOGLE_CLIENT_SECRET
5965
depends_on:
6066
- postgres
6167
networks:
6268
- spring-cloud-network
6369

64-
user-service:
65-
build: ./user-service
66-
container_name: user-service
70+
identity-service:
71+
build: ./identity-service
72+
container_name: identity-service
6773
ports:
68-
- "18080:8080"
74+
- "18081:8081"
6975
restart: always
7076
environment:
7177
- SPRING_DATASOURCE_URL
78+
- GOOGLE_CLIENT_ID
79+
- GOOGLE_CLIENT_SECRET
7280
depends_on:
7381
- postgres
82+
- user-service
7483
networks:
7584
- spring-cloud-network
7685

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.blubin.identityservice.controller;
2+
3+
import org.springframework.http.ResponseEntity;
4+
import org.springframework.web.bind.annotation.GetMapping;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
import org.springframework.web.bind.annotation.RestController;
7+
8+
@RestController
9+
@RequestMapping("/")
10+
public class HealthCheckController {
11+
@GetMapping
12+
public ResponseEntity<String> healthCheck() {
13+
return ResponseEntity.ok("Identity Service is running");
14+
}
15+
}

identity-service/src/main/resources/application.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ server:
44
grpc:
55
client:
66
user-service:
7-
address: "static://localhost:19090"
7+
# address: "static://localhost:19090"
8+
address: "static://user-service:19090" # for docker
9+
# address: "static://0.0.0.0:19090" # for docker
10+
# address: dns:///user-service:19090
811
negotiationType: plaintext
912

1013
spring:

protobuf/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM alpine:latest
2+
LABEL authors="binh"
3+
4+
WORKDIR /app
5+
COPY . .
6+
RUN apk add --no-cache protobuf

user-service/src/main/resources/application.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ server:
44
grpc:
55
server:
66
port: 19090
7+
address: 0.0.0.0
78

89
spring:
910
application:
10-
name: user_service
11+
name: user-service
1112
datasource:
1213
url: jdbc:postgresql://localhost:5432/ecommerce
1314
username: postgres

0 commit comments

Comments
 (0)