This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Dockerfile
59 lines (44 loc) · 2 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
ARG GO_VERSION=1.15
FROM golang:${GO_VERSION}-alpine AS builder
RUN mkdir /user \
&& echo 'daemon:x:2:2:daemon:/:' > /user/passwd \
&& echo 'daemon:x:2:' > /user/group
RUN apk add --no-cache ca-certificates git
RUN go get -u github.com/golang/dep/cmd/dep
WORKDIR ${GOPATH}/src/github.com/hiddeco/cronjobber
COPY ./Gopkg.toml ./Gopkg.lock ./
RUN dep ensure -vendor-only
COPY . ./
ARG VERSION
ARG VCS_REF
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w \
-X github.com/hiddeco/cronjobber/pkg/version.VERSION=${VERSION} \
-X github.com/hiddeco/cronjobber/pkg/version.REVISION=${VCS_REF}" \
-a -installsuffix 'static' -o /cronjobber ./cmd/cronjobber/*
FROM scratch AS cronjobber
# Static labels
LABEL maintainer="Hidde Beydals <hello@hidde.co>" \
org.opencontainers.image.title="cronjobber" \
org.opencontainers.image.description="Cronjobber is the Kubernetes cronjob controller patched with time zone support" \
org.opencontainers.image.url="https://github.com/hiddeco/cronjobber" \
org.opencontainers.image.source="git@github.com:hiddeco/cronjobber" \
org.opencontainers.image.vendor="Hidde Beydals" \
org.label-schema.schema-version="1.0" \
org.label-schema.name="cronjobber" \
org.label-schema.description="Cronjobber is the Kubernetes cronjob controller patched with time zone support" \
org.label-schema.url="https://github.com/hiddeco/cronjobber" \
org.label-schema.vcs-url="git@github.com:hiddeco/cronjobber" \
org.label-schema.vendor="Hidde Beydals"
COPY --from=builder /user/group /user/passwd /etc/
COPY --from=builder /cronjobber /cronjobber
USER daemon:daemon
ENTRYPOINT ["/cronjobber"]
ARG VCS_REF
ARG BUILD_DATE
# Dynamic labels
# Besides being informative these will also ensure each
# build ends up with a unique hash.
LABEL org.opencontainers.image.revision="$VCS_REF" \
org.opencontainers.image.created="$BUILD_DATE" \
org.label-schema.vcs-ref="$VCS_REF" \
org.label-schema.build-date="$BUILD_DATE"