forked from h2non/imaginary
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
64 lines (43 loc) · 1.9 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
FROM cgr.dev/chainguard/go:latest-dev@sha256:1a82b88f2e0045ab7167982093b984f64b3f9427f9ee1ebda3105a20f4d51f0d AS builder
ENV GOPATH=/go
ARG IMAGINARY_VERSION=dev
# Installs libvips + required libraries
RUN apk upgrade --no-cache --no-interactive \
&& apk add --no-cache --no-interactive ca-certificates libvips-dev
WORKDIR ${GOPATH}/src/github.com/sycured/imaginary
# Cache go modules
ENV GO111MODULE=on
COPY go.mod .
COPY go.sum .
RUN go mod download
# Copy imaginary sources
COPY . .
# Compile imaginary
RUN go build -a \
-o ${GOPATH}/bin/imaginary \
-ldflags="-s -w -h -X main.Version=${IMAGINARY_VERSION}" \
-trimpath \
github.com/sycured/imaginary
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:e1d402d624011d0f4439bfb0d46a3ddc692465103c7234a326e0194953c3cfe0
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/sycured/imaginary" \
org.label-schema.vcs-url="https://github.com/sycured/imaginary" \
org.label-schema.version="${IMAGINARY_VERSION}"
COPY --from=builder --chown=root:root --chmod=755 /go/bin/imaginary /usr/local/bin/imaginary
# Install runtime dependencies
RUN apk upgrade --no-cache --no-interactive \
&& apk add --no-cache --no-interactive ca-certificates jemalloc libvips \
&& ln -s /usr/lib/libjemalloc.so.2 /usr/local/lib/libjemalloc.so \
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/*
ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so
# Server port to listen
ENV PORT=9000
# Drop privileges for non-UID mapped environments
USER nobody
# Run the entrypoint command by default when the container starts.
ENTRYPOINT ["/usr/local/bin/imaginary"]
# Expose the server TCP port
EXPOSE ${PORT}