2020-04-25 18:18:33 +00:00
|
|
|
apiVersion: tekton.dev/v1beta1
|
|
|
|
kind: Task
|
|
|
|
metadata:
|
|
|
|
name: docker-build-and-publish
|
|
|
|
namespace: tekton-pipelines
|
|
|
|
spec:
|
|
|
|
params:
|
|
|
|
- name: DOCKERFILE
|
|
|
|
type: string
|
|
|
|
description: The path to the dockerfile to build
|
2020-09-11 19:56:46 +00:00
|
|
|
default: Dockerfile
|
2020-04-25 18:18:33 +00:00
|
|
|
- name: CONTEXT
|
|
|
|
type: string
|
|
|
|
description: The build context used by Docker.
|
2020-09-11 19:56:46 +00:00
|
|
|
default: .
|
2020-04-25 18:18:33 +00:00
|
|
|
- name: IMAGE
|
|
|
|
type: string
|
|
|
|
resources:
|
|
|
|
inputs:
|
|
|
|
- name: src
|
|
|
|
type: git
|
|
|
|
results:
|
|
|
|
- name: IMAGE_DIGEST
|
|
|
|
description: Digest of the image just built.
|
|
|
|
steps:
|
|
|
|
- name: build-and-push
|
|
|
|
workingDir: /workspace/src
|
2020-09-11 19:56:46 +00:00
|
|
|
image: moby/buildkit:latest
|
2020-04-25 18:18:33 +00:00
|
|
|
env:
|
|
|
|
- name: DOCKER_CONFIG
|
2020-09-11 19:56:46 +00:00
|
|
|
value: /root/.docker
|
2020-04-25 18:18:33 +00:00
|
|
|
command:
|
2020-09-11 20:24:58 +00:00
|
|
|
- sh
|
|
|
|
- -c
|
|
|
|
- |
|
|
|
|
PLATFORMS=$(grep 'PLATFORMS ?= ' Makefile | sed -E 's/^PLATFORMS \?= (.+)$/\1/')
|
|
|
|
if [ -z $PLATFORMS ]; then
|
|
|
|
PLATFORMS=linux/amd64
|
|
|
|
fi
|
|
|
|
|
|
|
|
buildctl-daemonless.sh --debug \
|
|
|
|
build \
|
|
|
|
--progress=plain \
|
|
|
|
--frontend=dockerfile.v0 \
|
|
|
|
--opt filename=$(params.DOCKERFILE) \
|
|
|
|
--opt platform=${PLATFORMS} \
|
|
|
|
--local context=$(params.CONTEXT) \
|
|
|
|
--local dockerfile=. \
|
|
|
|
--output type=image,name=$(params.IMAGE),push=true \
|
|
|
|
--export-cache type=inline \
|
|
|
|
--import-cache type=registry,ref=$(params.IMAGE)
|
2020-04-25 18:18:33 +00:00
|
|
|
securityContext:
|
2020-09-11 19:56:46 +00:00
|
|
|
privileged: true
|
2020-05-07 16:06:08 +00:00
|
|
|
volumeMounts:
|
|
|
|
- name: docker-config
|
2020-09-11 19:56:46 +00:00
|
|
|
mountPath: /root/.docker/config.json
|
2020-05-07 16:06:08 +00:00
|
|
|
subPath: config.json
|
|
|
|
volumes:
|
|
|
|
- name: docker-config
|
|
|
|
secret:
|
|
|
|
secretName: docker-config
|
|
|
|
|
|
|
|
|
|
|
|
|