Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

37 wiersze
1.3 KiB

  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. # 设置工作区
  9. WORKDIR /go/release
  10. # 把全部文件添加到/go/release目录
  11. ADD . .
  12. # 编译:把main.go编译成可执行的二进制文件,命名为egg_im
  13. RUN GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -o egg-im cmd/connect/main.go
  14. FROM ubuntu:xenial as prod
  15. LABEL maintainer="dengbiao"
  16. # 时区纠正
  17. ENV TZ="Asia/Shanghai"
  18. RUN rm -f /etc/localtime \
  19. && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
  20. && echo $TZ > /etc/timezone
  21. # 在build阶段复制可执行的go二进制文件app
  22. COPY --from=build /go/release/egg-im ./egg-im
  23. # 启动服务
  24. # 优化内核参数
  25. #RUN sysctl -w net.ipv4.tcp_fin_timeout=15
  26. #RUN sysctl -w net.ipv4.tcp_tw_recycle=1
  27. #RUN sysctl -w net.ipv4.ip_local_port_range=1024 65535
  28. #RUN sysctl -p
  29. #CMD ["bash","-c","sysctl -w net.ipv4.tcp_timestamps=1 && sysctl -w net.ipv4.tcp_tw_reuse=1 && sysctl -w net.ipv4.tcp_tw_timeout=10 && sysctl -w net.ipv4.tcp_fin_timeout=10 && sysctl -w net.ipv4.ip_local_port_range='1024 65535' && ./egg-im"]
  30. CMD ["./egg-im"]