#!groovy def repository = "registry.c.test-chamber-13.lan" def repositoryCreds = "harbor-repository-creds" def dockerFile = """ # Certificate Container FROM registry.c.test-chamber-13.lan/library/alpine:latest as certHost # Build Container FROM registry.c.test-chamber-13.lan/dockerhub/library/golang:alpine AS build COPY generic-sidecar-injector/ /go/src/app/ WORKDIR /go/src/app RUN set -x && \\ apk add --no-cache git upx gcc musl-dev && \\ addgroup -S -g 1000 app && \\ adduser --disabled-password -G app --gecos "application account" --home "/home/app" --shell "/sbin/nologin" --no-create-home --uid 1000 app && \\ go mod download && \\ GIT_HASH="\$(git rev-parse --short HEAD)" && \\ GIT_TAG="\$(git tag | tail -1)" && \\ CGO_ENABLED="0" && \\ GOOS="linux" && \\ GOARCH="amd64" && \\ go build \\ -v \\ -tags timetzdata \\ -ldflags="-s -w -X 'github.com/salesforce/generic-sidecar-injector/pkg/metrics.gitHash=\${GIT_HASH}' -X 'github.com/salesforce/generic-sidecar-injector/pkg/metrics.gitTag=\${GIT_TAG}'" \\ -installsuffix cgo \\ -o sidecarinjector \\ ./cmd/sidecarinjector && \\ upx --lzma sidecarinjector # Build Image from Scratch FROM registry.c.test-chamber-13.lan/library/alpine:latest LABEL maintainer="The_Spider " COPY --from=certHost /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=build /etc/passwd /etc/group /etc/ COPY --from=build --chown=app:app /go/src/app/sidecarinjector /app/sidecarinjector USER app:app WORKDIR /app/ ENTRYPOINT ["/app/sidecarinjector"] """ def label = "kubernetes-${UUID.randomUUID().toString()}" def templateName = "pipeline-worker" podTemplate( label: label, name: templateName, yaml: functions.podYaml( repo: repository, templateName: templateName, kaniko: true ) ) { node (label) { stage ("Pull generic-sidecar-injector source") { dir("generic-sidecar-injector") { checkout ([ $class: "GitSCM", branches: [ [ name: "refs/heads/master", ], ], userRemoteConfigs: [ [ url: "https://github.com/salesforce/generic-sidecar-injector.git", ], ], extensions: [ [ $class: "CloneOption", shallow: true, ], [ $class: "CheckoutOption", timeout: 2, ], ], ]) } } functions.buildContainer( repository: repository, imageDest: "${repository}/library/generic-sidecar-injector:latest-debug", dockerFile: dockerFile, repoCreds: repositoryCreds, ) } }