蛋蛋星球-客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Dockerfile-prd 1.4 KiB

2 週之前
2 週之前
2 週之前
2 週之前
2 週之前
1 周之前
2 週之前
2 週之前
2 週之前
2 週之前
2 週之前
2 週之前
2 週之前
12345678910111213141516171819202122232425262728293031323334353637383940
  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
  13. RUN GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -tags netgo -ldflags="-s -w" -installsuffix cgo -o egg main.go
  14. FROM ubuntu:xenial as prod
  15. LABEL maintainer="dengbiao"
  16. ENV TZ="Asia/Shanghai"
  17. COPY static/html static/html
  18. # 时区纠正
  19. RUN rm -f /etc/localtime \
  20. && ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  21. && echo "Asia/Shanghai" > /etc/timezone
  22. # 更新 CA 证书库
  23. RUN apt-get update && apt-get install -y ca-certificates
  24. # 在build阶段复制可执行的go二进制文件app
  25. COPY --from=build /go/release/egg ./egg
  26. COPY --from=build /go/release/etc/cfg.yml /var/egg/cfg.yml
  27. # 启动服务
  28. # CMD ["./egg","-c","/var/egg/cfg.yml"]
  29. 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 && ./egg -c /var/egg/cfg.yml"]