附近小店
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

há 2 meses
123456789101112131415161718192021222324252627282930313233343536373839
  1. # 多重构建,减少镜像大小
  2. # 构建:使用golang:1.18版本(直接使用自己从香港下载回来的镜像版本,提高打包速度)
  3. FROM registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/golang:1.18.4 as build
  4. # 容器环境变量添加,会覆盖默认的变量值
  5. ENV GO111MODULE=on
  6. ENV GOPROXY=https://goproxy.cn,direct
  7. ENV TZ="Asia/Shanghai"
  8. ENV PHONE_DATA_DIR="./static/bat"
  9. # 设置工作区
  10. WORKDIR /go/release
  11. # 把全部文件添加到/go/release目录
  12. ADD . .
  13. # 编译:把main.go编译成可执行的二进制文件,命名为zyos
  14. RUN GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -tags netgo -ldflags="-s -w" -installsuffix cgo -o zyos main.go
  15. FROM ubuntu:xenial as prod
  16. LABEL maintainer="zengzhengrong"
  17. ENV TZ="Asia/Shanghai"
  18. ENV PHONE_DATA_DIR="./static/bat"
  19. COPY static/html static/html
  20. COPY static/bat static/bat
  21. # 时区纠正
  22. RUN rm -f /etc/localtime \
  23. && ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  24. && echo "Asia/Shanghai" > /etc/timezone
  25. # 在build阶段复制可执行的go二进制文件app
  26. COPY --from=build /go/release/zyos ./zyos
  27. COPY --from=build /go/release/etc/cfg.yml /var/zyos/cfg.yml
  28. # 启动服务
  29. # CMD ["./zyos","-c","/var/zyos/cfg.yml"]
  30. CMD ["bash","-c","sysctl -w net.ipv4.tcp_tw_reuse=1 && sysctl -w net.ipv4.tcp_fin_timeout=10 && sysctl -w net.ipv4.ip_local_port_range='1024 65535' && sysctl -p && ./zyos -c /var/zyos/cfg.yml"]