WIP/POC: Initial commit.

This commit is contained in:
redxef 2022-08-29 18:28:23 +02:00
commit c185a04ec1
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921
6 changed files with 115 additions and 0 deletions

4
Dockerfile Normal file
View file

@ -0,0 +1,4 @@
FROM gcr.io/go-containerregistry/crane as crane
FROM alpine
COPY --from=crane /ko-app/crane /usr/local/bin/crane
RUN apk add --no-cache jq

67
ci/pipeline.yml Normal file
View file

@ -0,0 +1,67 @@
---
resources:
- name: source
type: git
source:
uri: https://gitea.redxef.at/redxef/concourse-oci-resource
branch: master
fetch_tags: true
- name: upstream-image
type: registry-image
source:
repository: alpine
jobs:
- name: build-push
plan:
- get: source
trigger: true
- get: upstream-image
trigger: true
- task: compute-docker-tags
config:
platform: linux
image_resource:
type: registry-image
source:
repository: alpine/git
inputs:
- name: source
path: .
outputs:
- name: docker-tags
run:
path: sh
args:
- -c
- |
#!/usr/bin/env sh
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
privileged: true
config:
platform: linux
image_resource:
type: registry-image
source:
repository: redxef/concourse-buildkit
tag: v0.2.1
inputs:
- name: source
path: .
- name: docker-tags
params:
username: ((docker.username))
password: ((docker.password))
repository: docker.io/redxef/concourse-oci-resource
tag: latest
additional_tags: docker-tags/tags.txt
push: true
platform: aarch64,arm,ppc64le,s390x,x86_64
context: .
manual: false
run:
path: build

11
src/check Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env sh
set -eu
. ./common
jq -r tostring << EOF
[
$(crane digest "$REPOSITORY:$TAG")
]
EOF

11
src/common Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env sh
INPUT_FILE="$(mktemp -t)"
cat > "$INPUT_FILE" <&0
export INPUT_FILE
REPOSITORY="$(jq -r .source.repository < "$INPUT_FILE")"
TAG="$(jq -r .source.tag < "$INPUT_FILE")"
export REPOSITORY
export TAG

11
src/in Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env sh
set -eu
. ./common
oci_dir="$(mktemp -d)"
crane pull --format=oci "$REPOSITORY:@$(jq -r .version "$INPUT_FILE")" "$oci_dir"
pushd "$oci_dir" && tar cf "$1/image.tar" && popd
echo "$(jq -r .version < "$INPUT_FILE")"

11
src/out Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env sh
set -eu
. ./common
IMAGE_REFS_FILE="$(mktemp -t)"
oci_dir="$(mktemp -d)"
pushd "$oci_dir" && tar xf "$1/$(jq -r .params.image < "$INPUT_FILE")" && popd
crane push "$1" "$REPOSITORY:$TAG" --image-refs="$IMAGE_REFS_FILE"
sed 's/^[^@]*@//' < "$IMAGE_REFS_FILE"