Im trying create docker-compose yaml file with configuration of grpc port but i have no i idea how to it. i research but not able to find any sample or to read by the this spring boot - grpc java
This configuration is working but grpc port is not showing if i run in termminal.
Im trying create docker-compose yaml file with configuration of grpc port but i have no i idea how to it. i research but not able to find any sample or to read by the this spring boot - grpc java
This configuration is working but grpc port is not showing if i run in termminal.
//appilication.yaml
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/dbpoc?characterEncoding=utf8&useSSL=false&autoReconnect=true
username: ${MYSQL_USER:root}
password: ${MYSQL_PASSWORD:root}
testWhileIdle: true
validationQuery: SELECT 1
sql:
init:
mode: always
continue-on-error: true
mvc:
throw-exception-if-no-handler-found: true
web:
resources:
add-mappings: false
grpc:
server:
port: 9090
//docker-compose.yaml
version: '3.8'
networks:
cartservice-net:
driver: bridge
services:
cartservice:
image: cartservice:latest
container_name: cartservice
depends_on:
- cart-mysqldb
restart: always
build:
context: ./
dockerfile: Dockerfile
networks:
- cartservice-net
environment:
MYSQL_HOST: cart-mysqldb
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_PORT: 3306
cart-mysqldb:
image: mysql:8.0.28
restart: unless-stopped
container_name: cart-mysqldb
ports:
- "3307:3306"
networks:
- cartservice-net
cap_add:
- SYS_NICE
environment:
MYSQL_DATABASE: dbpoc
MYSQL_ROOT_PASSWORD: root
//Dockerfile
FROM openjdk:8-jdk-alpine
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
CodePudding user response:
You need to add to your cartservice service the port tag so that you specify that this port needs to be exposed.
//docker-compose.yaml
version: '3.8'
networks:
cartservice-net:
driver: bridge
services:
cartservice:
image: cartservice:latest
container_name: cartservice
depends_on:
- cart-mysqldb
restart: always
build:
context: ./
dockerfile: Dockerfile
ports:
- "9090:9090"
networks:
- cartservice-net
environment:
MYSQL_HOST: cart-mysqldb
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_PORT: 3306
cart-mysqldb:
image: mysql:8.0.28
restart: unless-stopped
container_name: cart-mysqldb
ports:
- "3307:3306"
networks:
- cartservice-net
cap_add:
- SYS_NICE
environment:
MYSQL_DATABASE: dbpoc
MYSQL_ROOT_PASSWORD: root