Compare commits
9 commits
Author | SHA1 | Date | |
---|---|---|---|
9c9cd28de9 | |||
f7d3e95ef0 | |||
03513ee320 | |||
6d22bb3c51 | |||
9bc8d05101 | |||
92f27c55a5 | |||
37fabc96ee | |||
3641832ce8 | |||
7103d4760d |
3 changed files with 10 additions and 84 deletions
14
README.md
14
README.md
|
@ -1,21 +1,17 @@
|
||||||
# concourse-buildkit
|
# concourse-buildkit
|
||||||
|
|
||||||
A docker image to build multiarch images on [concourse](https://concourse-ci.org)
|
**DEPRECATED: this resource is no longer needed, the concourse build
|
||||||
since buildx is flakey for me.
|
task in combination with the registry-image can build and push multiarch
|
||||||
|
images now.**
|
||||||
|
|
||||||
Currently only the docker registry is supported.
|
A docker image to build multiarch images on [concourse](https://concourse-ci.org).
|
||||||
|
|
||||||
## parameters
|
## parameters
|
||||||
|
|
||||||
- repository: Required. The repository of the image.
|
- dest: Required. The output path for the oci 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,6 +8,7 @@ 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
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ 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,15 +1,5 @@
|
||||||
#!/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
|
||||||
|
@ -20,54 +10,13 @@ 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 "$repository" ]; then
|
if [ -z "$dest" ]; then
|
||||||
fail "missing argument: repository"
|
fail "missing argument: dest"
|
||||||
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=.
|
||||||
|
@ -78,36 +27,15 @@ 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=image,\"name="$final_tag"\",push="$push"
|
--output type=oci,dest="$dest"
|
||||||
}
|
}
|
||||||
|
|
||||||
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