adds sidecar injector
This commit is contained in:
parent
1bfe39c09d
commit
9aa2941513
96
build-sidecer-injector.jenkinsfile
Normal file
96
build-sidecer-injector.jenkinsfile
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#!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:latest AS build
|
||||||
|
|
||||||
|
COPY generic-sidecar-injector/ /go/src/app/
|
||||||
|
|
||||||
|
WORKDIR /go/src/app
|
||||||
|
|
||||||
|
RUN apk add --no-cache git upx && \\
|
||||||
|
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 scratch
|
||||||
|
|
||||||
|
LABEL maintainer="The_Spider <spider@smoothnet.org>"
|
||||||
|
|
||||||
|
COPY --from=certHost /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
COPY --from=builder /etc/passwd /etc/group /etc/
|
||||||
|
COPY --from=builder --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",
|
||||||
|
dockerFile: dockerFile,
|
||||||
|
repoCreds: repositoryCreds,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user