附近小店
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

Dockerfile-task 1.2 KiB

2 ay önce
1234567891011121314151617181920212223242526272829303132333435363738
  1. # 多重构建,减少镜像大小
  2. # 构建:使用golang:1.15版本
  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_order_task cmd/task/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_order_task ./zyos_order_task
  27. COPY --from=build /go/release/etc/task.yml /var/zyos/task.yml
  28. # 启动服务
  29. CMD ["./zyos_order_task","-c","/var/zyos/task.yml"]