diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..214ac78 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +fonts/* +output diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bc3f5e1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.7-alpine3.9 +LABEL MAINTAINER="soulteary " + +ENV LIBRARY_PATH /lib:/usr/lib + +RUN wget https://github.com/soulteary/gitbook2pdf/archive/master.zip -O /tmp/app.zip && \ + cd /tmp && unzip app.zip && mv /tmp/gitbook2pdf-master /app + +RUN apk add build-base python3-dev gcc musl-dev jpeg-dev zlib-dev libffi-dev cairo-dev pango-dev gdk-pixbuf-dev libxslt-dev && \ + cd /app && pip install -r /app/requirements.txt && \ + apk del build-base && rm -rf /var/cache/apk/* + +VOLUME [ "/app/output" ] +VOLUME [ "/usr/share/fonts/" ] + +WORKDIR /app + +ENTRYPOINT [ "python", "/app/gitbook.py" ] diff --git a/IMAGE_NAME.txt b/IMAGE_NAME.txt new file mode 100644 index 0000000..99b8918 --- /dev/null +++ b/IMAGE_NAME.txt @@ -0,0 +1 @@ +soulteary/docker-gitbook-pdf-generator:1.0.0 \ No newline at end of file diff --git a/build-with-mirror/Dockerfile b/build-with-mirror/Dockerfile new file mode 100644 index 0000000..f41a155 --- /dev/null +++ b/build-with-mirror/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.7-alpine3.9 +LABEL MAINTAINER="soulteary " + +ENV LIBRARY_PATH /lib:/usr/lib + +RUN wget https://github.com/soulteary/gitbook2pdf/archive/master.zip -O /tmp/app.zip && \ + cd /tmp && unzip app.zip && mv /tmp/gitbook2pdf-master /app + +RUN cat /etc/apk/repositories | sed -e "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/" | tee /etc/apk/repositories && \ + apk add build-base python3-dev gcc musl-dev jpeg-dev zlib-dev libffi-dev cairo-dev pango-dev gdk-pixbuf-dev libxslt-dev && \ + cd /app && pip install -i https://mirrors.aliyun.com/pypi/simple/ -r /app/requirements.txt && \ + apk del build-base && rm -rf /var/cache/apk/* + +VOLUME [ "/app/output" ] +VOLUME [ "/usr/share/fonts/" ] + +WORKDIR /app + +ENTRYPOINT [ "python", "/app/gitbook.py" ] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1a11139 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '2' + +services: + + pdf-generator: + image: soulteary/docker-gitbook-pdf-generator:1.0.0 + volumes: + - ./output:/app/output:rw + - ./fonts/:/usr/share/fonts:ro + command: "http://self-publishing.ebookchain.org" diff --git a/make-images.sh b/make-images.sh new file mode 100755 index 0000000..de863d2 --- /dev/null +++ b/make-images.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +if [[ "mirror"=="$1" ]]; then + docker build -t $(cat ./IMAGE_NAME.txt) . -f ./build-with-mirror/Dockerfile +else + docker build -t $(cat ./IMAGE_NAME.txt) . +fi;