-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.send-tools
61 lines (42 loc) · 1.55 KB
/
Dockerfile.send-tools
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
FROM devopsworks/golang-upx:1.22 as builder
ARG version
ARG builddate
LABEL org.opencontainers.image.base.name="devopsworks/send-cleanup"
LABEL org.opencontainers.image.description="Cleanup redis & gcs storages for firefox Send"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.ref.name="${version}-debian"
LABEL org.opencontainers.image.title="send-cleanup"
LABEL org.opencontainers.image.vendor="devops-works"
LABEL org.opencontainers.image.version="${version}"
WORKDIR /go/src/github.com/devops-works/send-tools
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y ca-certificates
# We want to populate the module cache based on the go.{mod,sum} files.
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
ENV GOPATH=/go/src \
GOOS=linux \
GOARCH=amd64 \
CGO_ENABLED=0 \
GO111MODULE=on
RUN go build \
-a \
-installsuffix cgo \
-ldflags "-X main.version=${version} -X main.buildDate=${builddate}" \
-o /go/bin/send-cleanup \
cmd/send-cleanup/main.go && \
strip /go/bin/send-cleanup && \
/usr/local/bin/upx -9 /go/bin/send-cleanup
# buster-slim alternative
FROM debian:buster-slim
RUN groupadd -r send-cleanup && useradd --no-log-init -r -g send-cleanup send-cleanup
# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*
RUN update-ca-certificates
COPY --from=builder /go/bin/send-cleanup /usr/local/bin/send-cleanup
USER send-cleanup
ENTRYPOINT ["/usr/local/bin/send-cleanup"]