Add more configurations.

This commit is contained in:
redxef 2022-03-09 16:02:03 +01:00
parent 572e0d27bc
commit 7cb4bda424
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921
2 changed files with 87 additions and 1 deletions

View file

@ -17,6 +17,26 @@ jobs:
trigger: true trigger: true
- get: upstream-image - get: upstream-image
trigger: true trigger: true
- task: compute-docker-tags:
config:
platform: linux
image_resource:
type: registry-image
source:
repository: alpine
inputs:
- name: source
path: .
outputs:
- name: docker-tags
run:
path: sh
args:
- -c
- |
#!/usr/bin/env sh
apk add --no-cache git
git rev-parse --short HEAD > docker-tags/tags.txt
- task: build - task: build
privileged: true privileged: true
config: config:
@ -28,9 +48,17 @@ jobs:
inputs: inputs:
- name: source - name: source
path: . path: .
- name: docker-tags
params: params:
username: ((docker.username)) username: ((docker.username))
password: ((docker.password)) password: ((docker.password))
repository: docker.io/redxef/concourse-buildkit
tag: latest
additional_tags: docker-tags/tags.txt
push: true
platform: aarch64,arm,ppc64le,s390x,x86_64
context: .
manual: false
run: run:
path: entrypoint.sh path: entrypoint.sh
args: args:

View file

@ -8,6 +8,11 @@ DOCKER_LOGIN_FILE_TMPL='{
} }
}' }'
fail() {
echo "Error:" "$@" 1>&2
exit 1
}
docker_login() { docker_login() {
# TODO: detect registry url # TODO: detect registry url
mkdir -p "$HOME/.docker" mkdir -p "$HOME/.docker"
@ -18,7 +23,60 @@ docker_login() {
} }
if [ -n "$username" ]; then if [ -n "$username" ]; then
if [ -z "$password" ]; then
fail "need to also give password when logging in"
fi
docker_login docker_login
fi fi
plain() {
buildctl-daemonless.sh "$@" buildctl-daemonless.sh "$@"
}
build() {
if [ -z "$repository" ]; then
fail "missing argument: repository"
fi
if [ -z "$tag" ]; then
tag=latest
fi
if [ -z "$push" ]; then
push=false
fi
if [ -z "$context" ]; then
context=.
fi
if [ -z "$platform" ]; then
platform=""
else
platform="--opt platform=$platform"
fi
final_tag="$repository:$tag"
if [ -z "$additional_tags" ]; then
while read -r line; do
if [ -z "$line" ]; then
continue
fi
final_tag="$final_tag,$repository:$line"
done < "$additional_tags"
fi
buildctl-daemonless.sh \
build \
--frontend dockerfile.v0 \
--local context="$context" \
--local dockerfile="$context" \
$platform \
--output type=image,\""$final_tag"\",push="$push"
}
if [ -z "$manual" ]; then
manual=false
fi
if "$manual"; then
plain "$@"
else
build
fi