118 lines
3.7 KiB
YAML
118 lines
3.7 KiB
YAML
{{- define "common.s2i-go" }}
|
|
{{- $common := dict "Values" .Values.common -}}
|
|
{{- $noCommon := omit .Values "common" -}}
|
|
{{- $overrides := dict "Values" $noCommon -}}
|
|
{{- $noValues := omit . "Values" -}}
|
|
{{- with merge $noValues $overrides $common -}}
|
|
apiVersion: tekton.dev/v1
|
|
kind: Task
|
|
metadata:
|
|
name: s2i-go
|
|
namespace: {{ .Release.Namespace }}
|
|
spec:
|
|
description: s2i-go task clones a Git repository and builds and pushes a container
|
|
image using S2I and a Go builder image.
|
|
params:
|
|
- default: "1.22"
|
|
description: The tag of go imagestream for go version
|
|
name: VERSION
|
|
type: string
|
|
- default: .
|
|
description: The location of the path to run s2i from.
|
|
name: PATH_CONTEXT
|
|
type: string
|
|
- default: "true"
|
|
description: Verify the TLS on the registry endpoint (for push/pull to a non-TLS
|
|
registry)
|
|
name: TLSVERIFY
|
|
type: string
|
|
- description: Location of the repo where image has to be pushed
|
|
name: IMAGE
|
|
type: string
|
|
- default: quay01.ipa.endofday.com/goghvideo/buildah:latest
|
|
description: The location of the buildah builder image.
|
|
name: BUILDER_IMAGE
|
|
type: string
|
|
- default: "false"
|
|
description: Skip pushing the built image
|
|
name: SKIP_PUSH
|
|
type: string
|
|
- description: Environment variables to set during _build-time_.
|
|
name: ENV_VARS
|
|
type: array
|
|
results:
|
|
- description: Digest of the image just built.
|
|
name: IMAGE_DIGEST
|
|
type: string
|
|
steps:
|
|
- args:
|
|
- $(params.ENV_VARS[*])
|
|
env:
|
|
- name: HOME
|
|
value: /tekton/home
|
|
image: quay01.ipa.endofday.com/goghvideo/openshift-pipeline-s2i:nightly
|
|
name: generate
|
|
script: |
|
|
echo "Processing Build Environment Variables"
|
|
echo "" > /env-vars/env-file
|
|
for var in "$@"
|
|
do
|
|
echo "$var" >> /env-vars/env-file
|
|
done
|
|
|
|
echo "Outputting Generated /env-vars/env-file"
|
|
cat /env-vars/env-file
|
|
|
|
s2i build $(params.PATH_CONTEXT) quay01.ipa.endofday.com/goghvideo/golang:$(params.VERSION) \
|
|
--as-dockerfile /gen-source/Dockerfile.gen --environment-file /env-vars/env-file
|
|
|
|
echo "Outputting Generated /gen-source/Dockerfile.gen file"
|
|
cat /gen-source/Dockerfile.gen
|
|
volumeMounts:
|
|
- mountPath: /gen-source
|
|
name: gen-source
|
|
- mountPath: /env-vars
|
|
name: env-vars
|
|
workingDir: $(workspaces.source.path)
|
|
securityContext:
|
|
runAsUser: 0
|
|
- image: $(params.BUILDER_IMAGE)
|
|
name: build-and-push
|
|
script: |
|
|
find . -type f -ls
|
|
|
|
buildah --log-level=info bud --storage-driver=vfs --tls-verify=$(params.TLSVERIFY) \
|
|
--layers -f /gen-source/Dockerfile.gen -t $(params.IMAGE) .
|
|
|
|
[[ "$(params.SKIP_PUSH)" == "true" ]] && echo "Push skipped" && exit 0
|
|
[[ "$(workspaces.dockerconfig.bound)" == "true" ]] && export DOCKER_CONFIG="$(workspaces.dockerconfig.path)"
|
|
buildah push --storage-driver=vfs --tls-verify=$(params.TLSVERIFY) \
|
|
--digestfile $(workspaces.source.path)/image-digest $(params.IMAGE) \
|
|
docker://$(params.IMAGE)
|
|
|
|
cat $(workspaces.source.path)/image-digest | tee /tekton/results/IMAGE_DIGEST
|
|
securityContext:
|
|
capabilities:
|
|
add:
|
|
- SETFCAP
|
|
volumeMounts:
|
|
- mountPath: /var/lib/containers
|
|
name: varlibcontainers
|
|
- mountPath: /gen-source
|
|
name: gen-source
|
|
workingDir: /gen-source
|
|
volumes:
|
|
- name: varlibcontainers
|
|
- name: gen-source
|
|
- name: env-vars
|
|
workspaces:
|
|
- mountPath: /workspace/source
|
|
name: source
|
|
- description: An optional workspace that allows providing a .docker/config.json
|
|
file for Buildah to access the container registry. The file should be placed
|
|
at the root of the Workspace with name config.json.
|
|
name: dockerconfig
|
|
optional: true
|
|
{{- end }}
|
|
{{- end }}
|