diff --git a/.dockerignore b/.dockerignore index e6583fc..30bf250 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,4 @@ **/.git target/ +docker/ +.dockerignore diff --git a/.gitignore b/.gitignore index ea8c4bf..a4c56f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +TODO.org diff --git a/Cargo.toml b/Cargo.toml index 5a6ced2..1afec1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ description = "Trigger tekton jobs with gitea webhooks." license = "0BSD" repository = "https://code.fizz.buzz/talexander/webhook_bridge" readme = "README.md" -keywords = ["gitea", "webhook"] +keywords = ["tekton", "gitea", "webhook"] categories = ["development-tools"] resolver = "2" include = [ diff --git a/docker/webhook_bridge/Dockerfile b/docker/webhook_bridge/Dockerfile new file mode 100644 index 0000000..0a9e7c8 --- /dev/null +++ b/docker/webhook_bridge/Dockerfile @@ -0,0 +1,15 @@ +FROM rustlang/rust:nightly-alpine3.20 AS builder + +RUN apk add --no-cache musl-dev pkgconfig libressl-dev + +RUN mkdir /source +WORKDIR /source +COPY . . +# 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 + +FROM alpine:3.20 AS runner + +COPY --from=builder /target/release-lto/webhook_bridge /usr/bin/ + +ENTRYPOINT ["/usr/bin/webhook_bridge"] diff --git a/docker/webhook_bridge/Makefile b/docker/webhook_bridge/Makefile new file mode 100644 index 0000000..a6f68e1 --- /dev/null +++ b/docker/webhook_bridge/Makefile @@ -0,0 +1,31 @@ +SHELL := bash +.ONESHELL: +.SHELLFLAGS := -eu -o pipefail -c +.DELETE_ON_ERROR: +MAKEFLAGS += --warn-undefined-variables +MAKEFLAGS += --no-builtin-rules + +ifeq ($(origin .RECIPEPREFIX), undefined) + $(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later) +endif +.RECIPEPREFIX = > + +IMAGE_NAME:=webhook-bridge +TARGET := + +.PHONY: help +help: +> @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1: /' + +.PHONY: build +build: ## Build the docker image. +> docker build --tag $(IMAGE_NAME) --target=$(TARGET) --file Dockerfile ../../ + +.PHONY: shell +shell: ## Launch an interactive shell inside the docker image with the source repository mounted at /source. +shell: build +> docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp $(IMAGE_NAME) + +.PHONY: clean +clean: +> docker rmi $(IMAGE_NAME)