Compare commits

..

No commits in common. "9c125f556222aea997d428b708c4fdcc5fb9cc1c" and "dbbe1acbc25077d868725efcf4447617493d3e68" have entirely different histories.

4 changed files with 25 additions and 19 deletions

View File

@ -1,25 +1,38 @@
FROM registry.cn-chengdu.aliyuncs.com/go_ls/go-zero:v1 AS builder
LABEL stage=gobuilder
ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn,direct
WORKDIR /src
COPY . .
RUN go mod tidy
RUN go build -ldflags="-s -w" -o /src/cmd/api/yl cmd/api/yl.go
# 创建最终镜像用于运行编译后的Go程序
FROM alpine
FROM registry.cn-chengdu.aliyuncs.com/go_ls/alpha:v1 AS runtime
RUN echo 'http://mirrors.ustc.edu.cn/alpine/v3.5/main' > /etc/apk/repositories \
&& echo 'http://mirrors.ustc.edu.cn/alpine/v3.5/community' >>/etc/apk/repositories \
&& apk update && apk add tzdata \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
&& echo "Asia/Shanghai" > /etc/timezone
# 设置工作目录
WORKDIR /app
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
# 将编译好的二进制文件从构建阶段复制到运行阶段
COPY cmd/api/yl /app/cmd/api/yl
COPY cmd/api/config /app/cmd/api/config
ENV TZ Asia/Shanghai
COPY --from=builder /src /src
#RUN mkdir "/var/log/supervisor"
#
#ADD ./sh/startup.sh /opt/startup.sh
#RUN sed -i 's/\r//g' /opt/startup.sh
#ADD ./sh/supervisord.conf /etc/supervisord.conf
WORKDIR /src
EXPOSE 10102
ENV TZ=Asia/Shanghai
# 设置容器启动时运行的命令
ENTRYPOINT ["/app/cmd/api/yl"]
#CMD ["sh","/opt/startup.sh"]
ENTRYPOINT ["/src/cmd/api/yl"]

View File

@ -5,7 +5,6 @@ Cache:
- Host: 47.97.27.195:6379
Pass: lansexiongdi@666
Nacos:
Timeout: 5000
Endpoints:
- 120.55.12.245:10001
Sys:

View File

@ -31,7 +31,6 @@ type Rpc struct {
}
type Nacos struct {
Timeout int64
Endpoints []string
}

View File

@ -18,13 +18,8 @@ type ServiceContext struct {
}
func NewServiceContext(c config.Config) *ServiceContext {
var timeOut int64 = 2000
if c.Nacos.Timeout > 2000 {
timeOut = c.Nacos.Timeout
}
client := transferClient.NewTransfer(zrpc.MustNewClient(zrpc.RpcClientConf{
Endpoints: c.Nacos.Endpoints,
Timeout: timeOut,
}))
sqlConn := sqlx.NewMysql(c.DB.Master.DataSource)