Dockerfile 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #前端预构建
  2. # FROM cmfont-cache:latest as builderFont
  3. # COPY /client .
  4. # RUN cnpm run build
  5. # 后端预构建
  6. #FROM cm-gocache:latest AS builder
  7. FROM golang:1.15-alpine AS builder
  8. RUN go env -w GO111MODULE=on
  9. RUN go env -w GOPROXY=https://goproxy.cn,direct
  10. COPY . /go/src/construction_management
  11. # 编译
  12. WORKDIR /go/src/construction_management/server/web
  13. #install 执行文件会生成在 gopath/bin 中
  14. RUN go install ./
  15. RUN ls ./external
  16. # 正式镜像
  17. FROM alpine:3.13
  18. # 安装nginx
  19. RUN echo http://mirrors.aliyun.com/alpine/v3.10/main>/etc/apk/repositories && \
  20. echo http://mirrors.aliyun.com/alpine/v3.10/community>>/etc/apk/repositories
  21. RUN apk update && apk upgrade \
  22. && apk add nginx \
  23. && mkdir /run/nginx \
  24. && touch /run/nginx.pid && \
  25. # chmod 755 /run.sh && \
  26. apk del m4 autoconf make gcc g++ linux-headers
  27. RUN find / -name ngnix.pid
  28. # 复制配置文件和前端文件
  29. # COPY --from=builder /go/src/construction_management/deployment/default.conf /etc/nginx/conf.d
  30. # COPY --from=builderFont /build /var/www/html/client
  31. # 后端相关
  32. # 把编译环境中编译好的 chat 复制到生产镜像中的 bin/chat 文件名称 不是目录
  33. #COPY --from=builder /go/bin/chat /bin/chat
  34. # /chat 放到根目录
  35. COPY --from=builder /go/bin/web /server
  36. COPY --from=builder /go/src/construction_management/server/web/config-debug.yaml /config-debug.yaml
  37. COPY --from=builder /go/src/construction_management/server/web/config-uat.yaml /config-uat.yaml
  38. COPY --from=builder /go/src/construction_management/server/web/config-pro.yaml /config-pro.yaml
  39. RUN mkdir -p /lib
  40. COPY --from=builder /go/src/construction_management/server/lib/*.json /lib/
  41. RUN chmod 777 /lib/*.json
  42. RUN chmod 777 /server
  43. RUN chmod 777 /config-debug.yaml
  44. RUN chmod 777 /config-uat.yaml
  45. RUN chmod 777 /config-pro.yaml
  46. ENV ADDR=:6060
  47. # 申明暴露的端口
  48. EXPOSE 80
  49. EXPOSE 6060
  50. # 设置服务入口
  51. # ENTRYPOINT ["/run.sh"]
  52. ENTRYPOINT ["sh","-c", "/server" ]
  53. # FROM centos:7
  54. # ADD /bin/ /
  55. # RUN chmod 777 /construction_management
  56. # ENV PARAMS=""
  57. # EXPOSE 6060
  58. # ENTRYPOINT ["sh","-c","/construction_management $PARAMS"]