Add more configurations.
This commit is contained in:
parent
572e0d27bc
commit
7cb4bda424
2 changed files with 87 additions and 1 deletions
|
@ -17,6 +17,26 @@ jobs:
|
|||
trigger: true
|
||||
- get: upstream-image
|
||||
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
|
||||
privileged: true
|
||||
config:
|
||||
|
@ -28,9 +48,17 @@ jobs:
|
|||
inputs:
|
||||
- name: source
|
||||
path: .
|
||||
- name: docker-tags
|
||||
params:
|
||||
username: ((docker.username))
|
||||
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:
|
||||
path: entrypoint.sh
|
||||
args:
|
||||
|
|
|
@ -8,6 +8,11 @@ DOCKER_LOGIN_FILE_TMPL='{
|
|||
}
|
||||
}'
|
||||
|
||||
fail() {
|
||||
echo "Error:" "$@" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
docker_login() {
|
||||
# TODO: detect registry url
|
||||
mkdir -p "$HOME/.docker"
|
||||
|
@ -18,7 +23,60 @@ docker_login() {
|
|||
}
|
||||
|
||||
if [ -n "$username" ]; then
|
||||
if [ -z "$password" ]; then
|
||||
fail "need to also give password when logging in"
|
||||
fi
|
||||
docker_login
|
||||
fi
|
||||
|
||||
plain() {
|
||||
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
|
||||
|
|
Reference in a new issue