[zeromicro/go-zero]goctl docker generate的用法

2020-11-20 915 views
5

请教一下大佬,bookstore中,我需要生成哪些dockerfile,怎么生成?然后怎么用? 如果需要在k8s中部署,有没有可以参考的配置文件? 谢谢

回答

4

有main函数的就需要生成 Dockerfilegoctl docker 命令可以生成

4

在哪一级目录执行这个命令

5

main函数所在的目录

0

可以了。多谢

5

做了一个docker-compose.yml

version: "3.8"
services:
  api:
    build:
      context: .
      dockerfile: ./api/Dockerfile
    depends_on:
      - add
      - check
    ports:
      - "8888:8888"
  add:
    build:
      context: .
      dockerfile: ./rpc/add/Dockerfile
    ports:
      - "8080:8080"
  check:
    build:
      context: .
      dockerfile: ./rpc/check/Dockerfile
    ports:
      - "8081:8081"      
1

服务可以正常工作,但是有这个警告

{"level":"warn","ts":"2020-11-21T09:02:53.463+0800","caller":"clientv3/retry_interceptor.go:62","msg":"retrying of unary invoker failed","target":"endpoint://client-c49f1602-2905-482a-ad97-242d7c7586db/xxx.xxx.xxx.xx:2379","attempt":0,"error":"rpc error: code = DeadlineExceeded desc = latest balancer error: all SubConns are in TransientFailure, latest connection error: connection error: desc = \"transport: Error while dialing dial tcp: lookup etcd on 127.0.0.11:53: no such host\""}

2

在main函数所在的目录下生成dockerfile文件会报这个错误 image 我现在的解决方案是在bookstore目录下生成多个dockerfile 文件,然后对rpc服务创建镜像的时候指定dockerfile文件名

9

就是需要在每个有main的目录执行 goctl docker -go <main.go>,然后在上级有 go.mod 的目录执行 docker build -t <img> -f <Dockerfile>

5

最新版里如果执行 docker build 的时候当前目录没有 go.mod 会报错

4

ok.已经可以了多谢大佬