Files
notifications-admin/docker/Dockerfile-build
Chris Hill-Scott 43296469d6 Add endpoint for generating an image of a letter
The PDF preview is all good, but it’s hard, finickeity and feels dirty
to embed a PDF in a web page. It’s a more natural thing to embed an
image in a web page.

So this commit adds another endpoint to return an image of a letter
template. It generates this image from the PDF preview, so the stack
looks like:

1. `template.png` (generated in admin)
2. `template.pdf` (generated in admin)
3. HTML preview (generated by a `Renderer` in utils)
4. `Template` instance
5. serialised template from API
6. Template stored in database

The library used to convert the PDF to an image is Wand[1], which binds
to ImageMagick underneath. So in order to get this working locally on a
Mac you will probably need to do:
`brew install imagemagick ghostscript cairo pango`.

To get it working on Ubuntu/EC2 is an exercise left to the reader…

1. http://docs.wand-py.org/en/0.4.4/
2016-12-13 10:34:18 +00:00

56 lines
1.1 KiB
Plaintext

FROM python:3.4-slim
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG NO_PROXY
ENV PYTHONUNBUFFERED=1 \
DEBIAN_FRONTEND=noninteractive \
NODEJS_VERSION=6.3.1-1nodesource1~jessie1
RUN \
echo "Install base packages" \
&& ([ -z "$HTTP_PROXY" ] || echo "Acquire::http::Proxy \"${HTTP_PROXY}\";\n" > /etc/apt/apt.conf.d/99HttpProxy) \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
make \
curl \
git \
build-essential \
libxml2-dev \
libxslt-dev \
zlib1g-dev \
zip \
rlwrap \
python-dev \
libffi-dev \
libssl-dev \
libexif-dev \
libfreetype6-dev \
libjpeg-dev \
liblcms2-2 \
libtiff5-dev \
zlib1g-dev \
libpango1.0-dev \
libcairo2-dev \
libmagickwand-dev \
ghostscript \
&& echo "Install nodejs" \
&& cd /tmp \
&& curl -sSLO https://deb.nodesource.com/node_6.x/pool/main/n/nodejs/nodejs_${NODEJS_VERSION}_amd64.deb \
&& dpkg -i /tmp/nodejs_${NODEJS_VERSION}_amd64.deb \
&& echo "Clean up" \
&& rm -rf /var/lib/apt/lists/* /tmp/*
RUN \
echo "Install global pip packages" \
&& pip install \
virtualenv \
awscli \
wheel
WORKDIR /var/project