From cc1c5829deedc60d74e2cebff0547788496e60a8 Mon Sep 17 00:00:00 2001 From: Michael Balsillie Date: Mon, 22 Aug 2022 10:54:01 +1200 Subject: [PATCH] create util container --- .woodpecker.yml | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 17 +++++++++++ README.md | 12 ++++++++ 3 files changed, 104 insertions(+) create mode 100644 .woodpecker.yml create mode 100644 Dockerfile create mode 100644 README.md diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..49a4b3d --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,75 @@ +variables: + &vars + - REGISTRY=code.balsillie.net + - REGISTRY_USER=michael + - SHOUTRRR_VERSION=SHOUTRRR_VERSION=v0.6.1 + - DOCKERFILE=Dockerfile + - CONTEXT=. + - MATRIX_HOST=matrix.balsillie.net + - MATRIX_PORT=443 + - MATRIX_ROOM=!HdSXmuHcBMaYExEfkh:balsillie.net + +workspace: + base: /git + path: pipeline + +clone: + git: + image: woodpeckerci/plugin-git + +pipeline: + + docker-build: + image: docker:latest + when: + - event: tag + volumes: + - /var/run/docker.sock:/var/run/docker.sock + environment: + *vars + secrets: + - source: REGISTRY_PASSWORD + target: REGISTRY_PASSWORD + commands: + - echo $REGISTRY_PASSWORD | docker login $REGISTRY -u $REGISTRY_USER --password-stdin + - docker build + -t $REGISTRY/${CI_REPO}:${CI_COMMIT_TAG} + -t $REGISTRY/${CI_REPO}:$(date +%F_%H-%M) + -t $REGISTRY/${CI_REPO}:latest + --pull + --build-arg $${SHOUTRRR_VERSION} + -f $${DOCKERFILE} + $${CONTEXT} + - docker push -a $REGISTRY/${CI_REPO} + + notify-matrix-success: + image: code.balsillie.net/containers/woodpecker-util + pull: false + when: + - event: tag + status: [ success ] + environment: + *vars + secrets: + - source: MATRIX_ACCESS_TOKEN + target: MATRIX_ACCESS_TOKEN + commands: + - shoutrrr send + --url matrix://$${MATRIX_ACCESS_TOKEN}@$${MATRIX_HOST}:$${MATRIX_PORT}/?rooms=$${MATRIX_ROOM} + --message "New image build of ${CI_REPO}, ${CI_COMMIT_TAG}, has been completed and pushed." + + notify-matrix-failure: + image: code.balsillie.net/containers/woodpecker-util + pull: false + when: + - event: tag + status: [ failure ] + environment: + *vars + secrets: + - source: MATRIX_ACCESS_TOKEN + target: MATRIX_ACCESS_TOKEN + commands: + - shoutrrr send + --url matrix://$${MATRIX_ACCESS_TOKEN}@$${MATRIX_HOST}:$${MATRIX_PORT}/?rooms=$${MATRIX_ROOM} + --message "New image build of ${CI_REPO}, ${CI_COMMIT_TAG}, has failed." \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ba859f5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +ARG SHOUTRRR_VERSION=v0.6.1 +FROM golang:bullseye AS builder +RUN git clone https://github.com/containrrr/shoutrrr.git shoutrrr \ + cd ./shoutrrr \ + git checkout ${SHOUTRRR_VERSION} \ + go build -o /output ./shoutrrr + +FROM debian:11-slim +RUN apt-get update && \ + apt-get install -y bash curl jq ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +RUN ln -sf /bin/bash /bin/sh +WORKDIR /root +COPY --from=builder /output ./shoutrrr +RUN chmod +x /root/shoutrrr/shoutrrr && \ + ln -sf /root/shoutrrr/shoutrrr /usr/bin/shoutrrr diff --git a/README.md b/README.md new file mode 100644 index 0000000..11a8db6 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +[![status-badge](https://pipeline.balsillie.net/api/badges/containers/woodpecker-util/status.svg)](https://pipeline.balsillie.net/containers/woodpecker-util) + +Utility container for use in Woodpecker CI builds. + +Debian:11-slim base with the following additional packchangesages: + + - Default to BASH shell. + - shoutrrr installed from source + - Packages installed from repo: + - curl + - jq + - ca-certificates