附近小店
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.
 
 
 

38 lines
1.1 KiB

  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. # 时区纠正
  21. RUN rm -f /etc/localtime \
  22. && ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  23. && echo "Asia/Shanghai" > /etc/timezone
  24. # 在build阶段复制可执行的go二进制文件app
  25. COPY --from=build /go/release/community_team_task ./community_team_task
  26. COPY --from=build /go/release/etc/task.yml /var/zyos/task.yml
  27. # 启动服务
  28. CMD ["./zyos_order_task","-c","/var/zyos/task.yml"]