Compare commits
No commits in common. "master" and "v0.2.0" have entirely different histories.
3 changed files with 84 additions and 10 deletions
14
README.md
14
README.md
|
@ -1,17 +1,21 @@
|
||||||
# concourse-buildkit
|
# concourse-buildkit
|
||||||
|
|
||||||
**DEPRECATED: this resource is no longer needed, the concourse build
|
A docker image to build multiarch images on [concourse](https://concourse-ci.org)
|
||||||
task in combination with the registry-image can build and push multiarch
|
since buildx is flakey for me.
|
||||||
images now.**
|
|
||||||
|
|
||||||
A docker image to build multiarch images on [concourse](https://concourse-ci.org).
|
Currently only the docker registry is supported.
|
||||||
|
|
||||||
## parameters
|
## parameters
|
||||||
|
|
||||||
- dest: Required. The output path for the oci image.
|
- repository: Required. The repository of the image.
|
||||||
|
- tag: Optional. The tag for the image, default: `latest`
|
||||||
|
- additional_tags: Optional. Path to a file containing one additional tag per line.
|
||||||
|
- push: Optional. Should the built image be pushed, default: `false`
|
||||||
- platform: Optional. A comma seperated list of target platforms, default: current platform
|
- platform: Optional. A comma seperated list of target platforms, default: current platform
|
||||||
- context: The context with which to build.
|
- context: The context with which to build.
|
||||||
- manual: Optional. Don't use params and instead supply all arguments via the command line, default: `false`
|
- manual: Optional. Don't use params and instead supply all arguments via the command line, default: `false`
|
||||||
|
- username: Optional. The username used to log into the registry.
|
||||||
|
- password: Optional. The password used to log into the registry.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ resources:
|
||||||
fetch_tags: true
|
fetch_tags: true
|
||||||
- name: upstream-image
|
- name: upstream-image
|
||||||
type: registry-image
|
type: registry-image
|
||||||
check_every: 6h
|
|
||||||
source:
|
source:
|
||||||
repository: moby/buildkit
|
repository: moby/buildkit
|
||||||
|
|
||||||
|
@ -49,7 +48,6 @@ jobs:
|
||||||
type: registry-image
|
type: registry-image
|
||||||
source:
|
source:
|
||||||
repository: redxef/concourse-buildkit
|
repository: redxef/concourse-buildkit
|
||||||
tag: v0.2.1
|
|
||||||
inputs:
|
inputs:
|
||||||
- name: source
|
- name: source
|
||||||
path: .
|
path: .
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
DEFAULT_DOMAIN=docker.io
|
||||||
|
LEGACY_DEFAULT_DOMAIN=index.docker.io
|
||||||
|
DOCKER_LOGIN_FILE_TMPL='{
|
||||||
|
"auths": {
|
||||||
|
"{{REGISTRY_URL}}": {
|
||||||
|
"auth": "{{BASE64_UNAME_PW}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
|
||||||
fail() {
|
fail() {
|
||||||
echo "Error:" "$@" 1>&2
|
echo "Error:" "$@" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -10,13 +20,54 @@ echo_and_run() {
|
||||||
"$@"
|
"$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
docker_login() {
|
||||||
|
login_name="$1"
|
||||||
|
if [ -z "$login_name" ]; then
|
||||||
|
login_name=docker.io
|
||||||
|
fi
|
||||||
|
# TODO: detect registry url
|
||||||
|
mkdir -p "$HOME/.docker"
|
||||||
|
echo "$DOCKER_LOGIN_FILE_TMPL" | \
|
||||||
|
sed -e "s|{{BASE64_UNAME_PW}}|$(printf '%s:%s' "$username" "$password" | base64)|g" \
|
||||||
|
-e "s|{{REGISTRY_URL}}|$login_name|g" \
|
||||||
|
> "$HOME/.docker/config.json"
|
||||||
|
}
|
||||||
|
|
||||||
plain() {
|
plain() {
|
||||||
buildctl-daemonless.sh "$@"
|
buildctl-daemonless.sh "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
split_repo_domain() {
|
||||||
|
domain_part="$(echo "$1" | sed -n 's|^\([^/]*\)/.*$|\1|p')"
|
||||||
|
other_part="$(echo "$1" | sed -n "s|^$domain_part/\?\(.*\)$|\1|p")"
|
||||||
|
|
||||||
|
if [ -z "$domain_part" ]; then
|
||||||
|
domain_part="$DEFAULT_DOMAIN"
|
||||||
|
other_part="$other_part"
|
||||||
|
elif echo "$domain_part" | grep -Evq '\.|:' && [ "$domain_part" != 'localhost' ]; then
|
||||||
|
# ^ docker sourcecode checks if $domain_part == $domain_part.lower() in effect checking if all is lower case
|
||||||
|
domain_part="$DEFAULT_DOMAIN"
|
||||||
|
other_part="$1" # we deviate here from the reference docker implementation
|
||||||
|
fi
|
||||||
|
if [ "$domain_part" = "$LEGACY_DEFAULT_DOMAIN" ]; then
|
||||||
|
domain_part="$DEFAULT_DOMAIN"
|
||||||
|
fi
|
||||||
|
if [ "$domain_part" = "$DEFAULT_DOMAIN" ] && echo "$other_part" | grep -vq /; then
|
||||||
|
other_part="library/$other_part"
|
||||||
|
fi
|
||||||
|
echo "$domain_part"
|
||||||
|
echo "$other_part"
|
||||||
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
if [ -z "$dest" ]; then
|
if [ -z "$repository" ]; then
|
||||||
fail "missing argument: dest"
|
fail "missing argument: repository"
|
||||||
|
fi
|
||||||
|
if [ -z "$tag" ]; then
|
||||||
|
tag=latest
|
||||||
|
fi
|
||||||
|
if [ -z "$push" ]; then
|
||||||
|
push=false
|
||||||
fi
|
fi
|
||||||
if [ -z "$context" ]; then
|
if [ -z "$context" ]; then
|
||||||
context=.
|
context=.
|
||||||
|
@ -27,15 +78,36 @@ build() {
|
||||||
platform="--opt platform=$platform"
|
platform="--opt platform=$platform"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
final_tag="$repository:$tag"
|
||||||
|
if [ -n "$additional_tags" ]; then
|
||||||
|
while read -r line; do
|
||||||
|
if [ -z "$line" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
final_tag="$repository:$line,$final_tag"
|
||||||
|
done < "$additional_tags"
|
||||||
|
fi
|
||||||
|
|
||||||
echo_and_run buildctl-daemonless.sh \
|
echo_and_run buildctl-daemonless.sh \
|
||||||
build \
|
build \
|
||||||
--frontend dockerfile.v0 \
|
--frontend dockerfile.v0 \
|
||||||
--local context="$context" \
|
--local context="$context" \
|
||||||
--local dockerfile="$context" \
|
--local dockerfile="$context" \
|
||||||
$platform \
|
$platform \
|
||||||
--output type=oci,dest="$dest"
|
--output type=image,\"name="$final_tag"\",push="$push"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ -n "$username" ]; then
|
||||||
|
if [ -z "$password" ]; then
|
||||||
|
fail "need to also give password when logging in"
|
||||||
|
fi
|
||||||
|
if [ -z "$repository" ]; then
|
||||||
|
docker_login "$DEFAULT_DOMAIN"
|
||||||
|
else
|
||||||
|
docker_login "$(split_repo_domain "$repository" | head -n1)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$manual" ]; then
|
if [ -z "$manual" ]; then
|
||||||
manual=false
|
manual=false
|
||||||
fi
|
fi
|
||||||
|
|
Reference in a new issue