Dockerfile 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. FROM golang:1.10.3-alpine3.7
  2. #新增 GLIBC
  3. ENV GLIBC_VERSION "2.28-r0"
  4. # Download and install glibc
  5. RUN apk add --update && \
  6. apk add --no-cache --upgrade \
  7. ca-certificates \
  8. gcc \
  9. g++ \
  10. make \
  11. curl \
  12. git
  13. RUN curl -Lo /etc/apk/keys/sgerrand.rsa.pub "https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub" && \
  14. curl -Lo /var/glibc.apk "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk" && \
  15. curl -Lo /var/glibc-bin.apk "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk" && \
  16. apk add /var/glibc-bin.apk /var/glibc.apk && \
  17. /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \
  18. echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
  19. #掛載 calibre 最新3.x
  20. ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/opt/calibre/lib
  21. ENV PATH $PATH:/opt/calibre/bin
  22. RUN curl -Lo /var/linux-installer.py https://download.calibre-ebook.com/linux-installer.py
  23. #RUN mkdir -p /go/src/github.com/lifei6671/ && cd /go/src/github.com/lifei6671/ && git clone https://github.com/lifei6671/mindoc.git && cd mindoc
  24. ADD . /go/src/github.com/lifei6671/mindoc
  25. WORKDIR /go/src/github.com/lifei6671/mindoc
  26. RUN go get -u github.com/golang/dep/cmd/dep && dep ensure && \
  27. CGO_ENABLE=1 go build -v -o mindoc_linux_amd64 -ldflags="-w -X main.VERSION=$TAG -X 'main.BUILD_TIME=`date`' -X 'main.GO_VERSION=`go version`'" && \
  28. rm -rf commands controllers models modules routers tasks vendor docs search data utils graphics .git Godeps uploads/* .gitignore .travis.yml Dockerfile gide.yaml LICENSE main.go README.md conf/enumerate.go conf/mail.go install.lock simsun.ttc
  29. ADD start.sh /go/src/github.com/lifei6671/mindoc
  30. ADD simsun.ttc /usr/share/fonts/win/
  31. FROM alpine:latest
  32. LABEL maintainer="[email protected]"
  33. RUN apk add --update && \
  34. apk add --no-cache --upgrade \
  35. ca-certificates \
  36. mesa-gl \
  37. python \
  38. qt5-qtbase-x11 \
  39. xdg-utils \
  40. libxrender \
  41. libxcomposite \
  42. xz \
  43. imagemagick \
  44. imagemagick-dev \
  45. msttcorefonts-installer \
  46. fontconfig && \
  47. update-ms-fonts && \
  48. fc-cache -f
  49. COPY --from=0 /var/glibc.apk .
  50. COPY --from=0 /var/glibc-bin.apk .
  51. COPY --from=0 /etc/apk/keys/sgerrand.rsa.pub /etc/apk/keys/sgerrand.rsa.pub
  52. COPY --from=0 /var/linux-installer.py .
  53. COPY --from=0 /usr/share/fonts/win/simsun.ttc /usr/share/fonts/win/
  54. RUN apk add glibc-bin.apk glibc.apk && \
  55. /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \
  56. echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \
  57. rm -rf glibc.apk glibc-bin.apk /var/cache/apk/* && \
  58. chmod a+r /usr/share/fonts/win/simsun.ttc
  59. ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/opt/calibre/lib
  60. ENV PATH $PATH:/opt/calibre/bin
  61. RUN cat linux-installer.py | python -c "import sys; main=lambda x,y:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main(install_dir='/opt', isolated=True)" && \
  62. rm -rf /tmp/* linux-installer.py
  63. WORKDIR /mindoc
  64. COPY --from=0 /go/src/github.com/lifei6671/mindoc .
  65. # 时区设置
  66. ENV TZ=Asia/Shanghai
  67. RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
  68. ENV ZONEINFO=/mindoc/lib/time/zoneinfo.zip
  69. RUN chmod +x start.sh
  70. CMD ["./start.sh"]