-
Notifications
You must be signed in to change notification settings - Fork 13
/
Dockerfile
181 lines (159 loc) · 5.04 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
FROM alpine as base
ENV LD_LIBRARY_PATH=/usr/local/lib
WORKDIR /tmp
FROM base as build
RUN apk add --no-cache build-base cmake nasm bash findutils
COPY script/extract ./
ENV CPATH=/usr/local/include
FROM build as libz
ARG LIBZ_VER
ARG LIBZ_SHA256
COPY download/libz-$LIBZ_VER.tar.gz download/
RUN ./extract libz && \
cd build/libz && \
./configure && \
make install
FROM libz as libpng
ARG LIBPNG_VER
ARG LIBPNG_SHA256
COPY download/libpng-$LIBPNG_VER.tar.gz download/
RUN ./extract libpng && \
cd build/libpng && \
./configure --with-zlib-prefix=/usr/local && \
make install
FROM libpng as liblcms
ARG LIBLCMS_VER
ARG LIBLCMS_SHA256
COPY download/liblcms-$LIBLCMS_VER.tar.gz download/
RUN ./extract liblcms && \
cd build/liblcms && \
./configure && \
make install
FROM build as libjpeg
ARG LIBJPEG_VER
ARG LIBJPEG_SHA256
COPY download/libjpeg-$LIBJPEG_VER.tar.gz download/
RUN ./extract libjpeg && \
cd build/libjpeg && \
./configure && \
make install
FROM build as libmozjpeg
ARG LIBMOZJPEG_VER
ARG LIBMOZJPEG_SHA256
COPY download/libmozjpeg-$LIBMOZJPEG_VER.tar.gz download/
RUN ./extract libmozjpeg && \
cd build/libmozjpeg && \
cmake -DPNG_SUPPORTED=0 . && \
make install
FROM libpng as advancecomp
ARG ADVANCECOMP_VER
ARG ADVANCECOMP_SHA256
COPY download/advancecomp-$ADVANCECOMP_VER.tar.gz download/
RUN ./extract advancecomp && \
cd build/advancecomp && \
./configure && \
make install
FROM build as gifsicle
ARG GIFSICLE_VER
ARG GIFSICLE_SHA256
COPY download/gifsicle-$GIFSICLE_VER.tar.gz download/
RUN ./extract gifsicle && \
cd build/gifsicle && \
./configure && \
make install
FROM build as jhead
ARG JHEAD_VER
ARG JHEAD_SHA256
COPY download/jhead-$JHEAD_VER.tar.gz download/
RUN ./extract jhead && \
cd build/jhead && \
make && \
install -c jhead /usr/local/bin
FROM libmozjpeg as jpegarchive
ARG JPEGARCHIVE_VER
ARG JPEGARCHIVE_SHA256
COPY download/jpegarchive-$JPEGARCHIVE_VER.tar.gz download/
RUN ./extract jpegarchive && \
cd build/jpegarchive && \
CFLAGS=-fcommon make install
FROM libjpeg as jpegoptim
ARG JPEGOPTIM_VER
ARG JPEGOPTIM_SHA256
COPY download/jpegoptim-$JPEGOPTIM_VER.tar.gz download/
RUN ./extract jpegoptim && \
cd build/jpegoptim && \
./configure && \
make install
FROM libpng as optipng
ARG OPTIPNG_VER
ARG OPTIPNG_SHA256
COPY download/optipng-$OPTIPNG_VER.tar.gz download/
RUN ./extract optipng && \
cd build/optipng && \
./configure && \
make install
FROM rust:1-alpine as oxipng
RUN apk add --no-cache build-base
COPY script/extract ./
ARG OXIPNG_VER
ARG OXIPNG_SHA256
COPY download/oxipng-$OXIPNG_VER.tar.gz download/
RUN ./extract oxipng && \
cd build/oxipng && \
cargo build --release && \
install -c target/release/oxipng /usr/local/bin
FROM libpng as pngcrush
ARG PNGCRUSH_VER
ARG PNGCRUSH_SHA256
COPY download/pngcrush-$PNGCRUSH_VER.tar.gz download/
COPY patches/pngcrush.patch patches/
RUN ./extract pngcrush && \
cd build/pngcrush && \
patch < ../../patches/pngcrush.patch && \
make && \
install -c pngcrush /usr/local/bin
FROM build as pngout
ARG PNGOUT_LINUX_STATIC_VER
ARG PNGOUT_LINUX_STATIC_SHA256
COPY download/pngout_linux_static-$PNGOUT_LINUX_STATIC_VER.tar.gz download/
RUN ./extract pngout_linux_static && \
cd build/pngout_linux_static && \
cp amd64/pngout-static /usr/local/bin/pngout
FROM liblcms as pngquant
ARG PNGQUANT_VER
ARG PNGQUANT_SHA256
COPY download/pngquant-$PNGQUANT_VER.tar.gz download/
RUN ./extract pngquant && \
cd build/pngquant && \
make install
# FROM build as [name]
# ARG [NAME]_VER
# ARG [NAME]_SHA256
# COPY download/[name]-$[NAME]_VER.tar.gz download/
# RUN ./extract [name] && \
# cd build/[name] && \
# ./configure && \
# make install
FROM base as image_optim
RUN apk add --no-cache libstdc++ ruby npm perl dumb-init
COPY README.markdown /
COPY acknowledgements /acknowledgements
COPY --from=advancecomp /usr/local/bin/advpng /usr/local/bin/
COPY --from=gifsicle /usr/local/bin/gifsicle /usr/local/bin/
COPY --from=jhead /usr/local/bin/jhead /usr/local/bin/
COPY --from=jpegarchive /usr/local/bin/jpeg-recompress /usr/local/bin/
COPY --from=jpegoptim /usr/local/bin/jpegoptim /usr/local/bin/
COPY --from=libjpeg /usr/local/bin/jpegtran /usr/local/bin/
COPY --from=optipng /usr/local/bin/optipng /usr/local/bin/
COPY --from=oxipng /usr/local/bin/oxipng /usr/local/bin/
COPY --from=pngcrush /usr/local/bin/pngcrush /usr/local/bin/
COPY --from=pngout /usr/local/bin/pngout /usr/local/bin/
COPY --from=pngquant /usr/local/bin/pngquant /usr/local/bin/
COPY --from=libjpeg /usr/local/lib/libjpeg.so.9 /usr/local/lib/
COPY --from=libpng /usr/local/lib/libpng16.so.16 /usr/local/lib/
COPY --from=libz /usr/local/lib/libz.so.1 /usr/local/lib/
COPY --from=liblcms /usr/local/lib/liblcms2.so.2 /usr/local/lib/
RUN npm -g install svgo
RUN gem install --no-document image_optim
ENTRYPOINT ["dumb-init", "image_optim"]
CMD ["--help"]