Skip to content

Commit

Permalink
Generate print.pdf during the CI build
Browse files Browse the repository at this point in the history
Part of whatwg/misc-server#7 for HTML.
  • Loading branch information
domenic authored and foolip committed Dec 1, 2017
1 parent 2c971f2 commit 32a8ef0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
22 changes: 22 additions & 0 deletions ci-deploy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@ RUN cd /whatwg/wattsi && \
/whatwg/wattsi/build.sh
ENV PATH="/whatwg/wattsi/bin:${PATH}"

ADD https://www.princexml.com/download/prince-11.3-linux-generic-x86_64.tar.gz /whatwg/prince.tar.gz

# Dependecies of prince_11.3-1_debian8.0_amd64.deb (not used) are libc6 libcurl3 libfontconfig1
# libfreetype6 libgif4 libgomp1 libjpeg62-turbo libpng12-0 libssl1.0.0 libtiff5 libxml2 zlib1g.
# Install the subset of that that's needed to make prince work and fonts.
RUN apt-get update && apt-get install -y libfontconfig1 libgomp1 libxml2 \
fonts-dejavu fonts-droid-fallback fonts-liberation fonts-symbola fonts-unfonts-core && \
cd /whatwg && \
tar xzf prince.tar.gz && \
echo /whatwg/prince | /whatwg/prince-11.3-linux-generic-x86_64/install.sh && \
echo '@font-face { font-family: serif; src: local("Symbola") }' >> /whatwg/prince/lib/prince/style/fonts.css && \
rm -rf /whatwg/prince.tar.gz /whatwg/prince-11.3-linux-generic-x86_64
ENV PATH="/whatwg/prince/bin:${PATH}"

ADD pdfsizeopt/pdfsizeopt.single /whatwg/pdfsizeopt/bin/pdfsizeopt
ADD https://github.com/pts/pdfsizeopt/releases/download/2017-01-24/pdfsizeopt_libexec_linux-v3.tar.gz /whatwg/pdfsizeopt_libexec.tar.gz
RUN cd /whatwg && \
tar xzf pdfsizeopt_libexec.tar.gz && \
mv pdfsizeopt_libexec/* pdfsizeopt/bin/ && \
rm -rf pdfsizeopt_libexec.tar.gz pdfsizeopt_libexec
ENV PATH="/whatwg/pdfsizeopt/bin:${PATH}"

ADD html-build /whatwg/html-build

# Note: we do not ADD /whatwg/html, but instead mount it using --volume in .travis.yml, since it
Expand Down
22 changes: 18 additions & 4 deletions ci-deploy/inside-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -o nounset
set -o pipefail
cd "$(dirname "$0")/../.."

PDF_SOURCE_URL="https://html.spec.whatwg.org/"
WEB_ROOT="html.spec.whatwg.org"
DEPLOY_USER="annevankesteren"

Expand Down Expand Up @@ -60,10 +61,6 @@ rsync --rsh="ssh -o UserKnownHostsFile=known_hosts" \
--archive --compress --verbose \
"$HTML_OUTPUT/index.html" "$DEPLOY_USER@$SERVER:$WEB_ROOT/commit-snapshots/$HTML_SHA"

# Tell remote web service to regenerate the PDF.
# It will ping us back when it's done.
curl http://sgr-a.ru/h/whatwgpdf.php

# Deploy everything to the new server as well.
echo "$NEW_SERVER $NEW_SERVER_PUBLIC_KEY" >> known_hosts

Expand All @@ -79,6 +76,23 @@ rsync --rsh="ssh -o UserKnownHostsFile=known_hosts" \
--archive --compress --verbose \
"$HTML_OUTPUT/index.html" "deploy@$NEW_SERVER:/var/www/$WEB_ROOT/commit-snapshots/$HTML_SHA"

echo ""
echo "Building PDF..."
PDF_TMP="$(mktemp --suffix=.pdf)"
prince --verbose --output "$PDF_TMP" "$PDF_SOURCE_URL"
pdfsizeopt "$PDF_TMP" "$HTML_OUTPUT/print.pdf"

echo ""
echo "Deploying PDF..."
rsync --rsh="ssh -o UserKnownHostsFile=known_hosts" \
--archive --compress --verbose \
"$HTML_OUTPUT/print.pdf" "$DEPLOY_USER@$SERVER:$WEB_ROOT/print.pdf"

echo ""
echo "Deploying PDF to new server..."
rsync --rsh="ssh -o UserKnownHostsFile=known_hosts" \
--archive --compress --verbose \
"$HTML_OUTPUT/print.pdf" "deploy@$NEW_SERVER:/var/www/$WEB_ROOT/print.pdf"
# TODO: deploy PDF to the new server as well

echo ""
Expand Down
4 changes: 3 additions & 1 deletion ci-deploy/outside-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST:-false}
# - DOCKER_PASSWORD is set from the outside
# - ENCRYPTION_LABEL is set from the outside

git clone https://github.com/whatwg/wattsi.git wattsi
git clone --depth 1 https://github.com/whatwg/wattsi.git wattsi

git clone --depth 1 https://github.com/pts/pdfsizeopt.git pdfsizeopt

# Copy the Docker-related stuff into the working (grandparent) directory.
cp "$HERE"/{.dockerignore,Dockerfile} .
Expand Down

0 comments on commit 32a8ef0

Please sign in to comment.