Compare commits
11 commits
Author | SHA1 | Date | |
---|---|---|---|
9c9cd28de9 | |||
f7d3e95ef0 | |||
03513ee320 | |||
6d22bb3c51 | |||
9bc8d05101 | |||
92f27c55a5 | |||
37fabc96ee | |||
3641832ce8 | |||
7103d4760d | |||
9fd0228d87 | |||
37efbb26ab |
3 changed files with 14 additions and 52 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
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,10 @@ resources:
|
||||||
source:
|
source:
|
||||||
uri: https://gitea.redxef.at/redxef/concourse-buildkit
|
uri: https://gitea.redxef.at/redxef/concourse-buildkit
|
||||||
branch: master
|
branch: master
|
||||||
|
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
|
||||||
|
|
||||||
|
@ -36,6 +38,9 @@ jobs:
|
||||||
- |
|
- |
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
git rev-parse --short HEAD > docker-tags/tags.txt
|
git rev-parse --short HEAD > docker-tags/tags.txt
|
||||||
|
git show-ref --tags | \
|
||||||
|
sed -n "/$(git rev-parse HEAD)/ s|$(git rev-parse HEAD).refs/tags/||gp" \
|
||||||
|
>> docker-tags/tags.txt
|
||||||
- task: build
|
- task: build
|
||||||
privileged: true
|
privileged: true
|
||||||
config:
|
config:
|
||||||
|
@ -44,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,13 +1,5 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
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
|
||||||
|
@ -18,35 +10,13 @@ echo_and_run() {
|
||||||
"$@"
|
"$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
docker_login() {
|
|
||||||
# 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}}|https://index.docker.io/v1/|g" \
|
|
||||||
> "$HOME/.docker/config.json"
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -n "$username" ]; then
|
|
||||||
if [ -z "$password" ]; then
|
|
||||||
fail "need to also give password when logging in"
|
|
||||||
fi
|
|
||||||
docker_login
|
|
||||||
fi
|
|
||||||
|
|
||||||
plain() {
|
plain() {
|
||||||
buildctl-daemonless.sh "$@"
|
buildctl-daemonless.sh "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
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=.
|
||||||
|
@ -57,23 +27,13 @@ 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 [ -z "$manual" ]; then
|
if [ -z "$manual" ]; then
|
||||||
|
|
Reference in a new issue