-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
134 lines (125 loc) · 4.32 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
FROM ruby:2.6.3-alpine
MAINTAINER SourceLevel <[email protected]>
# Based on https://github.com/toy/image_optim_pack/pull/5
ENV JPEGOPTIM_VERSION=1.4.3 \
PNGCRUSH_VERSION=1.7.88 \
ZOPFLI_VERSION=1.0.1 \
ADVANCECOMP_VERSION=1.20 \
JHEAD_VERSION=3.03 \
GIFSICLE_VERSION=1.88 \
OPTIPNG_VERSION=0.7.5 \
PNGQUANT_VERSION=2.5.2 \
JPEGARCHIVE_VERSION=2.1.1 \
MOZJPEG_VERSION=3.1 \
IJG_VERSION=9a \
PNGOUT_VERSION=20150319 \
SKIP_IMAGE_OPTIM_PACK=1
WORKDIR /tmp
# This step installs all external utilities, leaving only the
# compiled/installed binaries behind in order minimize the
# footprint of the image layer.
RUN apk update && apk add \
# Runtime dependencies
# advcomp (libstdc++.so, libgcc_s.so)
libstdc++ \
# jpegoptim (libjpeg.so)
libjpeg-turbo \
# pngquant
libpng \
# svgo
nodejs \
# build dependencies
&& apk add --virtual build-dependencies \
build-base \
# jpegoptim
libjpeg-turbo-dev \
# advancecomp
zlib-dev \
# pngquant
bash libpng-dev \
# mozjpeg
pkgconfig autoconf automake libtool nasm \
# Utilities
curl \
nodejs nodejs-npm \
# advancecomp
&& curl -L -O https://github.com/amadvance/advancecomp/releases/download/v$ADVANCECOMP_VERSION/advancecomp-$ADVANCECOMP_VERSION.tar.gz \
&& tar zxf advancecomp-$ADVANCECOMP_VERSION.tar.gz \
&& cd advancecomp-$ADVANCECOMP_VERSION \
&& ./configure && make && make install \
&& cd .. \
# gifsicle
&& curl -O https://www.lcdf.org/gifsicle/gifsicle-$GIFSICLE_VERSION.tar.gz \
&& tar zxf gifsicle-$GIFSICLE_VERSION.tar.gz \
&& cd gifsicle-$GIFSICLE_VERSION \
&& ./configure && make && make install \
&& cd .. \
# jhead
&& curl -O http://www.sentex.net/~mwandel/jhead/jhead-$JHEAD_VERSION.tar.gz \
&& tar zxf jhead-$JHEAD_VERSION.tar.gz \
&& cd jhead-$JHEAD_VERSION \
&& make && make install \
&& cd .. \
# jpegoptim
&& curl -O -L https://www.kokkonen.net/tjko/src/jpegoptim-$JPEGOPTIM_VERSION.tar.gz \
&& tar -xzf jpegoptim-$JPEGOPTIM_VERSION.tar.gz \
&& cd jpegoptim-$JPEGOPTIM_VERSION \
&& ./configure && make && make install \
&& cd .. \
# jpeg-recompress (from jpeg-archive along with mozjpeg dependency)
&& curl -L -O https://github.com/mozilla/mozjpeg/archive/v$MOZJPEG_VERSION.tar.gz \
&& tar zxf v$MOZJPEG_VERSION.tar.gz \
&& cd mozjpeg-$MOZJPEG_VERSION \
&& autoreconf -fiv && ./configure && make && make install \
&& cd .. \
&& curl -L -O https://github.com/danielgtaylor/jpeg-archive/archive/$JPEGARCHIVE_VERSION.tar.gz \
&& tar zxf $JPEGARCHIVE_VERSION.tar.gz \
&& cd jpeg-archive-$JPEGARCHIVE_VERSION \
&& make && make install \
&& cd .. \
# jpegtran (from Independent JPEG Group)
&& curl -O http://www.ijg.org/files/jpegsrc.v$IJG_VERSION.tar.gz \
&& tar zxf jpegsrc.v$IJG_VERSION.tar.gz \
&& cd jpeg-$IJG_VERSION \
&& ./configure && make && make install \
&& cd .. \
# optipng
&& curl -L -O http://downloads.sourceforge.net/project/optipng/OptiPNG/optipng-$OPTIPNG_VERSION/optipng-$OPTIPNG_VERSION.tar.gz \
&& tar zxf optipng-$OPTIPNG_VERSION.tar.gz \
&& cd optipng-$OPTIPNG_VERSION \
&& ./configure && make && make install \
&& cd .. \
# pngcrush
# && curl -O http://iweb.dl.sourceforge.net/project/pmt/pngcrush/$PNGCRUSH_VERSION/pngcrush-$PNGCRUSH_VERSION.tar.gz \
# && tar zxf pngcrush-$PNGCRUSH_VERSION.tar.gz \
# && cd pngcrush-$PNGCRUSH_VERSION \
# && make && cp -f pngcrush /usr/local/bin \
# && cd .. \
# pngout (binary distrib)
&& curl -O http://static.jonof.id.au/dl/kenutils/pngout-$PNGOUT_VERSION-linux-static.tar.gz \
&& tar zxf pngout-$PNGOUT_VERSION-linux-static.tar.gz \
&& cd pngout-$PNGOUT_VERSION-linux-static \
&& cp -f x86_64/pngout-static /usr/local/bin/pngout \
&& cd .. \
# pngquant
&& curl -L -O http://pngquant.org/pngquant-$PNGQUANT_VERSION-src.tar.bz2 \
&& tar xjf pngquant-$PNGQUANT_VERSION-src.tar.bz2 \
&& cd pngquant-$PNGQUANT_VERSION \
&& ./configure && make && make install \
&& cd .. \
# svgo
&& npm install -g svgo
WORKDIR /usr/src/app
COPY Gemfile /usr/src/app/
COPY Gemfile.lock /usr/src/app/
RUN apk --update add ruby ruby-dev ruby-bundler && \
bundle install -j 4 && \
# cleanup
rm -rf /usr/share/ri && \
rm -rf /tmp/* && \
apk del build-dependencies
RUN adduser -u 9000 -D app
COPY . /usr/src/app
RUN chown -R app:app /usr/src/app
USER app
CMD ["/usr/src/app/bin/engine-image-optim"]