Compare commits

...

6 Commits

Author SHA1 Message Date
Tom Alexander
3f2bdda8cb
Add support for new fields in payload. 2025-02-08 21:11:23 -05:00
Tom Alexander
e7eeeefa53
Add back in docker targets. 2024-10-20 23:12:52 -04:00
Tom Alexander
a17f6502c0
Use linked copy. 2024-10-20 23:03:40 -04:00
Tom Alexander
16a39809e4
Merge branch 'buildkit' 2024-10-20 22:42:36 -04:00
Tom Alexander
7dd0a9d0ad
Update dockerfiles to take advantage of BuildKit. 2024-10-20 22:35:16 -04:00
Tom Alexander
9d682cbe83
Switch to using BuiltKit instead of Kaniko to build docker images. 2024-10-20 22:28:04 -04:00
9 changed files with 226 additions and 83 deletions

@ -101,42 +101,74 @@ spec:
value: $(params.PULL_BASE_SHA) value: $(params.PULL_BASE_SHA)
- name: deleteExisting - name: deleteExisting
value: "true" value: "true"
- name: get-git-commit-time
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.20
computeResources:
requests:
cpu: 10m
memory: 600Mi
workingDir: "$(workspaces.repo.path)"
results:
- name: unix-time
description: The time of the git commit in unix timestamp format.
steps:
- image: alpine/git:v2.34.2
name: detect-tag-step
script: |
#!/usr/bin/env sh
set -euo pipefail
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
workspaces:
- name: repo
workspace: git-source
runAfter:
- fetch-repository
- name: build-image - name: build-image
taskRef: taskRef:
resolver: git resolver: git
params: params:
- name: url - name: url
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
- name: revision - name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
- name: pathInRepo - name: pathInRepo
value: task/kaniko/0.6/kaniko.yaml value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
params: params:
- name: IMAGE - name: OUTPUT
value: "$(params.image-name):$(tasks.detect-tag.results.tag)" value: >-
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.detect-tag.results.tag)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
- name: CONTEXT - name: CONTEXT
value: $(params.path-to-image-context) value: $(params.path-to-image-context)
- name: DOCKERFILE - name: DOCKERFILE
value: $(params.path-to-dockerfile) value: $(params.path-to-dockerfile)
- name: BUILDER_IMAGE
value: "gcr.io/kaniko-project/executor:v1.12.1"
- name: EXTRA_ARGS - name: EXTRA_ARGS
value: value:
- "--destination=$(params.image-name)" # Also write the :latest image - "--opt"
- "--target=$(params.target-name)" - "target=$(params.target-name)"
- --cache=true - --import-cache
- --cache-copy-layers - "type=registry,ref=$(params.image-name):buildcache"
- --cache-repo=harbor.fizz.buzz/kanikocache/cache - --export-cache
- --use-new-run # Should result in a speed-up - "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
- --reproducible # To remove timestamps so layer caching works. - --opt
- --snapshot-mode=redo - build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
- --skip-unused-stages=true - name: BUILDKITD_TOML
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local value: |
debug = true
[registry."docker.io"]
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
[registry."dockerhub.dockerhub.svc.cluster.local"]
http = true
insecure = true
workspaces: workspaces:
- name: source - name: source
workspace: git-source workspace: git-source
- name: dockerconfig - name: dockerconfig
workspace: docker-credentials workspace: docker-credentials
runAfter:
- fetch-repository
finally: finally:
- name: report-success - name: report-success
when: when:
@ -221,4 +253,4 @@ spec:
- name: path-to-image-context - name: path-to-image-context
value: . value: .
- name: path-to-dockerfile - name: path-to-dockerfile
value: docker/webhook_bridge/Dockerfile value: docker/webhook_bridge/

@ -69,41 +69,74 @@ spec:
value: $(params.PULL_BASE_SHA) value: $(params.PULL_BASE_SHA)
- name: deleteExisting - name: deleteExisting
value: "true" value: "true"
- name: get-git-commit-time
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.20
computeResources:
requests:
cpu: 10m
memory: 600Mi
workingDir: "$(workspaces.repo.path)"
results:
- name: unix-time
description: The time of the git commit in unix timestamp format.
steps:
- image: alpine/git:v2.34.2
name: detect-tag-step
script: |
#!/usr/bin/env sh
set -euo pipefail
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
workspaces:
- name: repo
workspace: git-source
runAfter:
- fetch-repository
- name: build-image - name: build-image
taskRef: taskRef:
resolver: git resolver: git
params: params:
- name: url - name: url
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
- name: revision - name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
- name: pathInRepo - name: pathInRepo
value: task/kaniko/0.6/kaniko.yaml value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
params: params:
- name: IMAGE - name: OUTPUT
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)" value: >-
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
- name: CONTEXT - name: CONTEXT
value: $(params.path-to-image-context) value: $(params.path-to-image-context)
- name: DOCKERFILE - name: DOCKERFILE
value: $(params.path-to-dockerfile) value: $(params.path-to-dockerfile)
- name: BUILDER_IMAGE
value: "gcr.io/kaniko-project/executor:v1.12.1"
- name: EXTRA_ARGS - name: EXTRA_ARGS
value: value:
- "--target=$(params.target-name)" - "--opt"
- --cache=true - "target=$(params.target-name)"
- --cache-copy-layers - --import-cache
- --cache-repo=harbor.fizz.buzz/kanikocache/cache - "type=registry,ref=$(params.image-name):buildcache"
- --use-new-run # Should result in a speed-up - --export-cache
- --reproducible # To remove timestamps so layer caching works. - "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
- --snapshot-mode=redo - --opt
- --skip-unused-stages=true - build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local - name: BUILDKITD_TOML
value: |
debug = true
[registry."docker.io"]
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
[registry."dockerhub.dockerhub.svc.cluster.local"]
http = true
insecure = true
workspaces: workspaces:
- name: source - name: source
workspace: git-source workspace: git-source
- name: dockerconfig - name: dockerconfig
workspace: docker-credentials workspace: docker-credentials
runAfter:
- fetch-repository
- name: run-cargo-fmt - name: run-cargo-fmt
taskSpec: taskSpec:
metadata: {} metadata: {}
@ -143,7 +176,7 @@ spec:
- build-image - build-image
params: params:
- name: docker-image - name: docker-image
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)" value: "$(tasks.build-image.results.IMAGE_URL[1])"
- name: commit-changes - name: commit-changes
taskRef: taskRef:
resolver: git resolver: git
@ -268,7 +301,7 @@ spec:
workspace: cargo-cache workspace: cargo-cache
params: params:
- name: docker-image - name: docker-image
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)" value: "$(tasks.build-image.results.IMAGE_URL[1])"
workspaces: workspaces:
- name: git-source - name: git-source
- name: docker-credentials - name: docker-credentials
@ -298,4 +331,4 @@ spec:
- name: path-to-image-context - name: path-to-image-context
value: docker/webhook_bridge_development/ value: docker/webhook_bridge_development/
- name: path-to-dockerfile - name: path-to-dockerfile
value: docker/webhook_bridge_development/Dockerfile value: docker/webhook_bridge_development/

@ -69,41 +69,74 @@ spec:
value: $(params.PULL_BASE_SHA) value: $(params.PULL_BASE_SHA)
- name: deleteExisting - name: deleteExisting
value: "true" value: "true"
- name: get-git-commit-time
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.20
computeResources:
requests:
cpu: 10m
memory: 600Mi
workingDir: "$(workspaces.repo.path)"
results:
- name: unix-time
description: The time of the git commit in unix timestamp format.
steps:
- image: alpine/git:v2.34.2
name: detect-tag-step
script: |
#!/usr/bin/env sh
set -euo pipefail
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
workspaces:
- name: repo
workspace: git-source
runAfter:
- fetch-repository
- name: build-image - name: build-image
taskRef: taskRef:
resolver: git resolver: git
params: params:
- name: url - name: url
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
- name: revision - name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
- name: pathInRepo - name: pathInRepo
value: task/kaniko/0.6/kaniko.yaml value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
params: params:
- name: IMAGE - name: OUTPUT
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)" value: >-
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
- name: CONTEXT - name: CONTEXT
value: $(params.path-to-image-context) value: $(params.path-to-image-context)
- name: DOCKERFILE - name: DOCKERFILE
value: $(params.path-to-dockerfile) value: $(params.path-to-dockerfile)
- name: BUILDER_IMAGE
value: "gcr.io/kaniko-project/executor:v1.12.1"
- name: EXTRA_ARGS - name: EXTRA_ARGS
value: value:
- "--target=$(params.target-name)" - "--opt"
- --cache=true - "target=$(params.target-name)"
- --cache-copy-layers - --import-cache
- --cache-repo=harbor.fizz.buzz/kanikocache/cache - "type=registry,ref=$(params.image-name):buildcache"
- --use-new-run # Should result in a speed-up - --export-cache
- --reproducible # To remove timestamps so layer caching works. - "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
- --snapshot-mode=redo - --opt
- --skip-unused-stages=true - build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local - name: BUILDKITD_TOML
value: |
debug = true
[registry."docker.io"]
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
[registry."dockerhub.dockerhub.svc.cluster.local"]
http = true
insecure = true
workspaces: workspaces:
- name: source - name: source
workspace: git-source workspace: git-source
- name: dockerconfig - name: dockerconfig
workspace: docker-credentials workspace: docker-credentials
runAfter:
- fetch-repository
- name: run-cargo-clippy - name: run-cargo-clippy
taskSpec: taskSpec:
metadata: {} metadata: {}
@ -153,7 +186,7 @@ spec:
- build-image - build-image
params: params:
- name: docker-image - name: docker-image
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)" value: "$(tasks.build-image.results.IMAGE_URL[1])"
finally: finally:
- name: report-success - name: report-success
when: when:
@ -247,7 +280,7 @@ spec:
workspace: cargo-cache workspace: cargo-cache
params: params:
- name: docker-image - name: docker-image
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)" value: "$(tasks.build-image.results.IMAGE_URL[1])"
workspaces: workspaces:
- name: git-source - name: git-source
- name: docker-credentials - name: docker-credentials
@ -277,4 +310,4 @@ spec:
- name: path-to-image-context - name: path-to-image-context
value: docker/webhook_bridge_development/ value: docker/webhook_bridge_development/
- name: path-to-dockerfile - name: path-to-dockerfile
value: docker/webhook_bridge_development/Dockerfile value: docker/webhook_bridge_development/

@ -69,41 +69,74 @@ spec:
value: $(params.PULL_BASE_SHA) value: $(params.PULL_BASE_SHA)
- name: deleteExisting - name: deleteExisting
value: "true" value: "true"
- name: get-git-commit-time
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.20
computeResources:
requests:
cpu: 10m
memory: 600Mi
workingDir: "$(workspaces.repo.path)"
results:
- name: unix-time
description: The time of the git commit in unix timestamp format.
steps:
- image: alpine/git:v2.34.2
name: detect-tag-step
script: |
#!/usr/bin/env sh
set -euo pipefail
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
workspaces:
- name: repo
workspace: git-source
runAfter:
- fetch-repository
- name: build-image - name: build-image
taskRef: taskRef:
resolver: git resolver: git
params: params:
- name: url - name: url
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
- name: revision - name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
- name: pathInRepo - name: pathInRepo
value: task/kaniko/0.6/kaniko.yaml value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
params: params:
- name: IMAGE - name: OUTPUT
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)" value: >-
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
- name: CONTEXT - name: CONTEXT
value: $(params.path-to-image-context) value: $(params.path-to-image-context)
- name: DOCKERFILE - name: DOCKERFILE
value: $(params.path-to-dockerfile) value: $(params.path-to-dockerfile)
- name: BUILDER_IMAGE
value: "gcr.io/kaniko-project/executor:v1.12.1"
- name: EXTRA_ARGS - name: EXTRA_ARGS
value: value:
- "--target=$(params.target-name)" - "--opt"
- --cache=true - "target=$(params.target-name)"
- --cache-copy-layers - --import-cache
- --cache-repo=harbor.fizz.buzz/kanikocache/cache - "type=registry,ref=$(params.image-name):buildcache"
- --use-new-run # Should result in a speed-up - --export-cache
- --reproducible # To remove timestamps so layer caching works. - "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
- --snapshot-mode=redo - --opt
- --skip-unused-stages=true - build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local - name: BUILDKITD_TOML
value: |
debug = true
[registry."docker.io"]
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
[registry."dockerhub.dockerhub.svc.cluster.local"]
http = true
insecure = true
workspaces: workspaces:
- name: source - name: source
workspace: git-source workspace: git-source
- name: dockerconfig - name: dockerconfig
workspace: docker-credentials workspace: docker-credentials
runAfter:
- fetch-repository
- name: run-cargo-test - name: run-cargo-test
taskSpec: taskSpec:
metadata: {} metadata: {}
@ -143,7 +176,7 @@ spec:
- build-image - build-image
params: params:
- name: docker-image - name: docker-image
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)" value: "$(tasks.build-image.results.IMAGE_URL[1])"
finally: finally:
- name: report-success - name: report-success
when: when:
@ -237,7 +270,7 @@ spec:
workspace: cargo-cache workspace: cargo-cache
params: params:
- name: docker-image - name: docker-image
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)" value: "$(tasks.build-image.results.IMAGE_URL[1])"
workspaces: workspaces:
- name: git-source - name: git-source
- name: docker-credentials - name: docker-credentials
@ -267,4 +300,4 @@ spec:
- name: path-to-image-context - name: path-to-image-context
value: docker/webhook_bridge_development/ value: docker/webhook_bridge_development/
- name: path-to-dockerfile - name: path-to-dockerfile
value: docker/webhook_bridge_development/Dockerfile value: docker/webhook_bridge_development/

@ -1,15 +1,18 @@
FROM rustlang/rust:nightly-alpine3.20 AS builder # syntax=docker/dockerfile:1
ARG ALPINE_VERSION="3.20"
FROM rustlang/rust:nightly-alpine$ALPINE_VERSION AS builder
RUN apk add --no-cache musl-dev pkgconfig libressl-dev RUN apk add --no-cache musl-dev pkgconfig libressl-dev
RUN mkdir /source RUN mkdir /source
WORKDIR /source WORKDIR /source
COPY . . COPY --link . .
# TODO: Add static build, which currently errors due to proc_macro. RUSTFLAGS="-C target-feature=+crt-static" # TODO: Add static build, which currently errors due to proc_macro. RUSTFLAGS="-C target-feature=+crt-static"
RUN CARGO_TARGET_DIR=/target cargo build --profile release-lto --bin webhook_bridge RUN --mount=type=tmpfs,target=/tmp --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked CARGO_TARGET_DIR=/target cargo build --profile release-lto --bin webhook_bridge
FROM alpine:3.20 AS runner FROM alpine:$ALPINE_VERSION AS runner
COPY --from=builder /target/release-lto/webhook_bridge /usr/bin/ COPY --link --from=builder /target/release-lto/webhook_bridge /usr/bin/
ENTRYPOINT ["/usr/bin/webhook_bridge"] ENTRYPOINT ["/usr/bin/webhook_bridge"]

@ -1,6 +1,9 @@
FROM rustlang/rust:nightly-alpine3.20 AS builder # syntax=docker/dockerfile:1
ARG ALPINE_VERSION="3.20"
FROM rustlang/rust:nightly-alpine$ALPINE_VERSION AS builder
RUN apk add --no-cache musl-dev pkgconfig libressl3.8-libssl libressl-dev RUN apk add --no-cache musl-dev pkgconfig libressl3.8-libssl libressl-dev
RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache RUN --mount=type=tmpfs,target=/tmp --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked cargo install --locked --no-default-features --features ci-autoclean cargo-cache
RUN rustup component add rustfmt RUN rustup component add rustfmt
RUN rustup component add clippy RUN rustup component add clippy

@ -4,4 +4,4 @@ set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
RUST_LOG=webhook_bridge=DEBUG WEBHOOK_BRIDGE_API_ROOT="https://code.fizz.buzz/api" WEBHOOK_BRIDGE_HMAC_SECRET=$(cat /bridge/git/mrmanager/k8s/webhook-bridge/secrets/webhook-bridge/webhook-bridge/HMAC_TOKEN) WEBHOOK_BRIDGE_OAUTH_TOKEN=$(cat /bridge/git/mrmanager/k8s/webhook-bridge/secrets/webhook-bridge/webhook-bridge/OAUTH_TOKEN) cargo run RUST_LOG=webhook_bridge=DEBUG WEBHOOK_BRIDGE_API_ROOT="https://code.fizz.buzz/api" WEBHOOK_BRIDGE_HMAC_SECRET=$(cat /bridge/git/mrmanager/k8s/webhook_bridge/secrets/webhook-bridge/webhook-bridge/HMAC_TOKEN) WEBHOOK_BRIDGE_OAUTH_TOKEN=$(cat /bridge/git/mrmanager/k8s/webhook_bridge/secrets/webhook-bridge/webhook-bridge/OAUTH_TOKEN) WEBHOOK_BRIDGE_REPO_WHITELIST="talexander/webhook_bridge,talexander/homepage,talexander/natter,talexander/poudboot,talexander/ta_waybar_pipewire,talexander/organic" cargo run

4
rust-toolchain.toml Normal file

@ -0,0 +1,4 @@
[toolchain]
channel = "nightly"
profile = "default"
components = ["clippy", "rustfmt"]

@ -113,6 +113,8 @@ pub(crate) struct HookRepository {
object_format_name: String, object_format_name: String,
mirror_updated: String, // TODO: parse to datetime mirror_updated: String, // TODO: parse to datetime
repo_transfer: Value, // Was null in test hook repo_transfer: Value, // Was null in test hook
topics: Value, // Was null in test hook
licenses: Value, // Was null in test hook
} }
#[allow(dead_code)] #[allow(dead_code)]