Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Rebase cronjobber to latest cronjob code using kubebuilder
Browse files Browse the repository at this point in the history
- Build with kubebuilder(3.3.0)
- Go 1.17
- Rebased to latest native cronjob
- using time/tzdata for tz database

Fixes: #20
  • Loading branch information
Kiran Kothule committed Mar 10, 2022
1 parent 4ae4a73 commit 5ed9fe2
Show file tree
Hide file tree
Showing 103 changed files with 15,743 additions and 5,384 deletions.
8 changes: 0 additions & 8 deletions .dockerignore

This file was deleted.

86 changes: 27 additions & 59 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,59 +1,27 @@
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 <[email protected]>" \
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="[email protected]: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="[email protected]: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"
# Build the manager binary
FROM golang:1.17 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532

ENTRYPOINT ["/manager"]
Loading

0 comments on commit 5ed9fe2

Please sign in to comment.