-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
94 lines (77 loc) · 3.17 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
ARG GOLANG="1.11.5"
FROM golang:${GOLANG} as builder
ARG IMAGINARY_VERSION="dev"
ARG LIBVIPS_VERSION="8.7.4"
ARG GOLANG
# Installs libvips + required libraries
RUN DEBIAN_FRONTEND=noninteractive \
apt-get update && \
apt-get install --no-install-recommends -y \
ca-certificates \
automake build-essential curl \
gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg62-turbo-dev libpng-dev \
libwebp-dev libtiff5-dev libgif-dev libexif-dev libxml2-dev libpoppler-glib-dev \
swig libmagickwand-dev libpango1.0-dev libmatio-dev libopenslide-dev libcfitsio-dev \
libgsf-1-dev fftw3-dev liborc-0.4-dev librsvg2-dev && \
cd /tmp && \
curl -fsSLO https://github.com/libvips/libvips/releases/download/v${LIBVIPS_VERSION}/vips-${LIBVIPS_VERSION}.tar.gz && \
tar zvxf vips-${LIBVIPS_VERSION}.tar.gz && \
cd /tmp/vips-${LIBVIPS_VERSION} && \
CFLAGS="-g -O3" CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0 -g -O3" \
./configure \
--disable-debug \
--disable-dependency-tracking \
--disable-introspection \
--disable-static \
--enable-gtk-doc-html=no \
--enable-gtk-doc=no \
--enable-pyvips8=no && \
make && \
make install && \
ldconfig && \
GO111MODULE=off go get -u github.com/golang/dep/cmd/dep
# Installing golangci-lint
WORKDIR /tmp
RUN curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GOPATH}/bin" v1.16.0
WORKDIR ${GOPATH}/src/github.com/h2non/imaginary
# Copy imaginary sources
COPY . .
# Making sure all dependencies are up-to-date
RUN rm -rf vendor && dep ensure
# Run quality control
RUN GO111MODULE=off go test -test.v -test.race -test.covermode=atomic ./...
RUN GO111MODULE=off golangci-lint run ./...
# Compile imaginary
RUN GO111MODULE=off go build -a \
-o ${GOPATH}/bin/imaginary \
-ldflags="-s -w -h -X main.Version=${IMAGINARY_VERSION}" \
github.com/h2non/imaginary
FROM debian:stretch-slim
ARG IMAGINARY_VERSION
LABEL maintainer="[email protected]" \
org.label-schema.description="Fast, simple, scalable HTTP microservice for high-level image processing with first-class Docker support" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://github.com/h2non/imaginary" \
org.label-schema.vcs-url="https://github.com/h2non/imaginary" \
org.label-schema.version="${IMAGINARY_VERSION}"
COPY --from=builder /usr/local/lib /usr/local/lib
COPY --from=builder /go/bin/imaginary /usr/local/bin/imaginary
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
# Install runtime dependencies
RUN DEBIAN_FRONTEND=noninteractive \
apt-get update && \
apt-get install --no-install-recommends -y \
libglib2.0-0 libjpeg62-turbo libpng16-16 libopenexr22 \
libwebp6 libwebpmux2 libtiff5 libgif7 libexif12 libxml2 libpoppler-glib8 \
libmagickwand-6.q16-3 libpango1.0-0 libmatio4 libopenslide0 \
libgsf-1-114 fftw3 liborc-0.4 librsvg2-2 libcfitsio5 && \
apt-get autoremove -y && \
apt-get autoclean && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Server port to listen
ENV PORT 9000
# Run the entrypoint command by default when the container starts.
ENTRYPOINT ["/usr/local/bin/imaginary"]
# Expose the server TCP port
EXPOSE ${PORT}