diff --git a/Dockerfile b/Dockerfile index 2c33e18a..f3c90fd5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,88 @@ FROM golang:1.10.3-alpine3.7 -# add china aliyun repo 新增了 alpine 3.6 的阿里源 -RUN cp /etc/apk/repositories /etc/apk/repositories.back && \ - echo "https://mirrors.aliyun.com/alpine/v3.6/main/" > /etc/apk/repositories && \ - echo "https://mirrors.aliyun.com/alpine/v3.6/community/" >> /etc/apk/repositories +#新增 GLIBC +ENV GLIBC_VERSION 2.27-r0 -RUN apk add --update bash git make gcc g++ +# Download and install glibc +RUN apk add --update && \ + apk add --no-cache --upgrade \ + ca-certificates \ + gcc \ + g++ \ + make \ + curl \ + git -ADD . /go/src/github.com/lifei6671/mindoc +RUN curl -Lo /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub && \ + curl -Lo /var/glibc.apk "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk" && \ + curl -Lo /var/glibc-bin.apk "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk" && \ + apk add /var/glibc-bin.apk /var/glibc.apk && \ + /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \ + echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf + +#掛載 calibre 最新3.x + +ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/opt/calibre/lib +ENV PATH $PATH:/opt/calibre/bin + +RUN curl -Lo /var/linux-installer.py https://download.calibre-ebook.com/linux-installer.py + +RUN mkdir -p /go/src/github.com/lifei6671/ && cd /go/src/github.com/lifei6671/ && git clone https://github.com/lifei6671/mindoc.git && cd mindoc WORKDIR /go/src/github.com/lifei6671/mindoc -RUN go get -u github.com/golang/dep/cmd/dep && dep ensure && \ - 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`'" && \ - 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 +RUN go get -u github.com/golang/dep/cmd/dep && dep ensure && \ + 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`'" && \ + 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 + +ADD start.sh /go/src/github.com/lifei6671/mindoc FROM alpine:latest + LABEL maintainer="longfei6671@163.com" + +RUN apk add --update && \ + apk add --no-cache --upgrade \ + ca-certificates \ + mesa-gl \ + python \ + qt5-qtbase-x11 \ + xdg-utils \ + libxrender \ + libxcomposite \ + xz \ + imagemagick \ + imagemagick-dev \ + msttcorefonts-installer \ + fontconfig && \ + update-ms-fonts && \ + fc-cache -f + +COPY --from=0 /var/glibc.apk . +COPY --from=0 /var/glibc-bin.apk . +COPY --from=0 /etc/apk/keys/sgerrand.rsa.pub /etc/apk/keys/sgerrand.rsa.pub +COPY --from=0 /var/linux-installer.py . +ADD simsun.ttc /usr/share/fonts/win/ + +RUN chmod a+r /usr/share/fonts/win/simsun.ttc + +RUN apk add glibc-bin.apk glibc.apk && \ + /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \ + echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \ + rm -rf glibc.apk glibc-bin.apk /var/cache/apk/* + + +ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/opt/calibre/lib +ENV PATH $PATH:/opt/calibre/bin + +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)" && \ + rm -rf /tmp/* linux-installer.py + WORKDIR /mindoc + COPY --from=0 /go/src/github.com/lifei6671/mindoc . + + ENV ZONEINFO=/mindoc/lib/time/zoneinfo.zip RUN chmod +x start.sh