Dockerfile 2.1 KB

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