Dockerfile 2.1 KB

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