forked from imgproxy/imgproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
88 lines (75 loc) · 2.72 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
FROM alpine:edge
LABEL maintainer="Sergey Alexandrovich <[email protected]>"
ENV GOPATH /go
ENV PATH /usr/local/go/bin:$PATH
ADD . /go/src/github.com/DarthSim/imgproxy
WORKDIR /go/src/github.com/DarthSim/imgproxy
# Install dependencies
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk --no-cache upgrade \
&& apk add --no-cache curl ca-certificates go gcc g++ make musl-dev fftw-dev glib-dev expat-dev \
libjpeg-turbo-dev libpng-dev libwebp-dev giflib-dev libexif-dev lcms2-dev
# Build ImageMagick
RUN cd /root \
&& mkdir ImageMagick \
&& curl -Ls https://imagemagick.org/download/ImageMagick.tar.gz | tar -xz -C ImageMagick --strip-components 1 \
&& cd ImageMagick \
&& ./configure \
--enable-silent-rules \
--disable-static \
--disable-openmp \
--disable-deprecated \
--disable-docs \
--with-threads \
--without-magick-plus-plus \
--without-utilities \
--without-perl \
--without-bzlib \
--without-dps \
--without-freetype \
--without-jbig \
--without-jpeg \
--without-lcms \
--without-lzma \
--without-png \
--without-tiff \
--without-wmf \
--without-xml \
--without-webp \
&& make install-strip
# Build libvips
RUN cd /root \
&& export VIPS_VERSION=$(curl -s "https://api.github.com/repos/libvips/libvips/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') \
&& echo "Vips version: $VIPS_VERSION" \
&& curl -Ls https://github.com/libvips/libvips/releases/download/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.gz | tar -xz \
&& cd vips-$VIPS_VERSION \
&& ./configure \
--disable-magickload \
--without-python \
--without-tiff \
--without-orc \
--without-OpenEXR \
--enable-debug=no \
--disable-static \
--enable-silent-rules \
&& make install-strip
# Build imgproxy
RUN cd /go/src/github.com/DarthSim/imgproxy \
&& CGO_LDFLAGS_ALLOW="-s|-w" go build -v -o /usr/local/bin/imgproxy
# Copy compiled libs here to copy them to the final image
RUN cd /root \
&& mkdir libs \
&& ldd /usr/local/bin/imgproxy | grep /usr/local/lib/ | awk '{print $3}' | xargs -I '{}' cp '{}' libs/
# ==================================================================================================
# Final image
FROM alpine:edge
LABEL maintainer="Sergey Alexandrovich <[email protected]>"
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk --no-cache upgrade \
&& apk add --no-cache bash ca-certificates fftw glib expat libjpeg-turbo libpng \
libwebp giflib libexif lcms2 \
&& rm -rf /var/cache/apk*
COPY --from=0 /usr/local/bin/imgproxy /usr/local/bin/
COPY --from=0 /root/libs/* /usr/local/lib/
CMD ["imgproxy"]
EXPOSE 8080