From f77a3604eefb561357af07f5d052a2820788f9a8 Mon Sep 17 00:00:00 2001 From: Werner Beroux Date: Tue, 19 Apr 2016 10:59:02 +0200 Subject: [PATCH] Uses Linux Alpine as base image to reduce image by about 65%. - Reduce image from about 413 MB to about 144 MB. - Changes default font (Purisa isn't easy to install on Linux Alpine). --- .editorconfig | 3 +++ Dockerfile | 59 ++++++++++++++++++++++++++++-------------------- requirements.txt | 6 ++--- 3 files changed, 40 insertions(+), 28 deletions(-) diff --git a/.editorconfig b/.editorconfig index 8f96039..ce7a6be 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,3 +8,6 @@ end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true + +[*.yml] +indent_size = 2 diff --git a/Dockerfile b/Dockerfile index dffbb38..f30a544 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,41 +1,50 @@ -FROM debian:jessie +FROM alpine:3.3 MAINTAINER Werner Beroux COPY . /opt/scruffy-server -RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - fonts-tlwg-purisa \ - git \ +RUN set -x \ + && apk add --update \ graphviz \ - libjpeg-dev \ - librsvg2-bin \ - plotutils \ + libjpeg \ + librsvg \ + python \ + py-pillow \ + zlib \ + && apk add -t .build-deps \ + make \ + g++ \ + git \ python-dev \ - python-pil \ - python-pip \ - python-setuptools \ - zlib1g-dev \ - - && git clone https://github.com/aivarsk/scruffy.git /opt/scruffy \ - && cd /opt/scruffy \ - && python setup.py install \ + py-pip \ + py-setuptools \ + zlib-dev \ + + && mkdir -p /usr/share/fonts/opentype/dion \ + && cd /usr/share/fonts/opentype/dion \ + && wget -O dion.zip 'http://dl.dafont.com/dl/?f=dion' \ + && unzip dion.zip \ + && rm dion.zip \ + && fc-cache -f -v \ + + && wget -O- https://mirrors.kernel.org/gnu/plotutils/plotutils-2.6.tar.gz | tar -xz -C /tmp \ + && cd /tmp/plotutils-2.6 \ + && ./configure \ + && make install \ + && make installcheck \ + && cd pic2plot \ + && make install \ && cd - \ - && rm -rf scruffy \ + && rm -rf /tmp/plotutils-2.6 \ && cd /opt/scruffy-server \ && pip install -r requirements.txt \ - && apt-get purge --auto-remove -y \ - git \ - python-dev \ - python-pip \ - python-setuptools \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ + && apk del --purge .build-deps \ + && rm /var/cache/apk/* \ - && useradd --system --uid 35726 -m --shell /usr/sbin/nologin scruffy + && adduser -S -u 35726 -s /sbin/nologin scruffy # Run as non-root user USER scruffy diff --git a/requirements.txt b/requirements.txt index dd9ebcd..59a77d8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -bottle==0.12.8 -Pillow==2.8.2 -reportlab==3.2.0 +bottle==0.12.9 +Pillow>=2.3 +reportlab==3.3.0 scruffy==0.3 svglib==0.6.3