# 启动编译环境 FROM golang:1.17 # 配置编译环境 RUN go env -w GO111MODULE=on RUN go env -w GOPROXY=https://goproxy.cn,direct # 拷贝源代码的镜像中 COPY . /go/src/coolcar/server # 编译 WORKDIR /go/src/coolcar/server RUN go install ./gateway/... # 设置服务入口 ENTRYPOINT [ "/go/bin/gateway" ]
# 启动编译环境,使用golang-alpine的环境 FROM golang:1.17-alpine as builder # 配置编译环境 RUN go env -w GO111MODULE=on RUN go env -w GOPROXY=https://goproxy.cn,direct # 拷贝源代码的镜像中 COPY . /go/src/coolcar/server # 编译 WORKDIR /go/src/coolcar/server RUN go install ./gateway/...
# 二次编译 FROM alpine:3.13 # 将编译的文件放在/bin目录下 COPY --from=builder /go/bin/gateway /bin/gateway
var addr = flag.String("addr", ":8080", "address to listen") var authAddr = flag.String("auth_addr", "localhost:8081", "address for auth service") var tripAddr = flag.String("trip_addr", "localhost:8082", "address for trip service") var profileAddr = flag.String("profile_addr", "localhost:8082", "address for profile service") var carAddr = flag.String("car_addr", "localhost:8084", "address for car service")
在main函数中一点要运行
1
flag.Parse()
2.auth中配置
1 2 3 4 5
var addr = flag.String("addr", ":8081", "address to listen") var mongoURI = flag.String("mongo_uri", "mongodb://localhost:27017", "mongo uri") var privateKeyFile = flag.String("private_key_file", "auth/private.key", "private key file") var wechatAppID = flag.String("wechat_app_id", "<APPID>", "wechat app id") var wechatAppSecret = flag.String("wechat_app_secret", "<APPSECRET>", "wechat app secret")
2.blob中配置
1 2 3 4 5
var addr = flag.String("addr", ":8083", "address to listen") var mongoURI = flag.String("mongo_uri", "mongodb://localhost:27017", "mongo uri") var cosAddr = flag.String("cos_addr", "<URL>", "cos address") var cosSecID = flag.String("cos_sec_id", "<SEC_ID>", "cos secret id") var cosSecKey = flag.String("cos_sec_key", "<SEC_KEY>", "cos secret key")
3.car配置
1 2 3 4 5 6 7
var addr = flag.String("addr", ":8084", "address to listen") var wsAddr = flag.String("ws_addr", ":9090", "websocket address to listen") var mongoURI = flag.String("mongo_uri", "mongodb://localhost:27017", "mongo uri") var amqpURL = flag.String("amqp_url", "amqp://guest:guest@localhost:5672/", "amqp url") var carAddr = flag.String("car_addr", "localhost:8084", "address for car service") var tripAddr = flag.String("trip_addr", "localhost:8082", "address for trip service") var aiAddr = flag.String("ai_addr", "localhost:18001", "address for ai service")
4.rental配置
1 2 3 4 5
var addr = flag.String("addr", ":8082", "address to listen") var mongoURI = flag.String("mongo_uri", "mongodb://localhost:27017", "mongo uri") var blobAddr = flag.String("blob_addr", "localhost:8083", "address for blob service") var carAddr = flag.String("car_addr", "localhost:8084", "address for car service") var authPublicKeyFile = flag.String("auth_public_key_file", "shared/auth/public.key", "public key file for auth")
# 启动编译环境,使用golang-alpine的环境 FROM golang:1.17-alpine as builder # 配置编译环境 RUN go env -w GO111MODULE=on RUN go env -w GOPROXY=https://goproxy.cn,direct # 拷贝源代码的镜像中 COPY . /go/src/coolcar/server # 编译 WORKDIR /go/src/coolcar/server RUN go install ./auth/...
# 启动编译环境,使用golang-alpine的环境 FROM golang:1.17-alpine as builder # 配置编译环境 RUN go env -w GO111MODULE=on RUN go env -w GOPROXY=https://goproxy.cn,direct # 拷贝源代码的镜像中 COPY . /go/src/coolcar/server # 编译 WORKDIR /go/src/coolcar/server RUN go install ./car/...