如何docker 将客户端和服务端都组合成grpc?
How to docker compose grpc both client and server?
我正在尝试使用 grpc 端口的配置创建 docker-compose yaml 文件,但我不知道该怎么做。我研究但无法找到任何示例或通过此 spring 引导阅读 - grpc java
此配置有效,但 grpc 端口未显示,如果我 运行 在终端中。
我正在尝试使用 grpc 端口的配置创建 docker-compose yaml 文件,但我不知道该怎么做。我研究但无法找到任何示例或通过此 spring 引导阅读 - grpc java
此配置有效,但 grpc 端口未显示,如果我 运行 在终端中。
//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"]
您需要将端口标记添加到您的 cartservice 服务,以便您指定需要公开此端口。
//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
我正在尝试使用 grpc 端口的配置创建 docker-compose yaml 文件,但我不知道该怎么做。我研究但无法找到任何示例或通过此 spring 引导阅读 - grpc java
此配置有效,但 grpc 端口未显示,如果我 运行 在终端中。
我正在尝试使用 grpc 端口的配置创建 docker-compose yaml 文件,但我不知道该怎么做。我研究但无法找到任何示例或通过此 spring 引导阅读 - grpc java
此配置有效,但 grpc 端口未显示,如果我 运行 在终端中。
//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"]
您需要将端口标记添加到您的 cartservice 服务,以便您指定需要公开此端口。
//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