From aea097240e927aa7575d6c6db1065de2a2977f63 Mon Sep 17 00:00:00 2001 From: Dominik Meyer Date: Tue, 9 Jan 2024 22:01:54 +0100 Subject: [PATCH] ADD: initial commit --- .drone.yml | 82 +++++++++++++++++++++++++++++++++++++ Containerfile | 25 +++++++++++ LICENSE | 21 ++++++++++ README.md | 50 ++++++++++++++++++++++ scripts/entryPoint.sh | 13 ++++++ scripts/setupEnvironment.sh | 3 ++ 6 files changed, 194 insertions(+) create mode 100644 .drone.yml create mode 100644 Containerfile create mode 100644 LICENSE create mode 100644 README.md create mode 100755 scripts/entryPoint.sh create mode 100755 scripts/setupEnvironment.sh diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..5eaa6f8 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,82 @@ +kind: pipeline +type: kubernetes +name: build-amd64 +platform: + arch: amd64 +node_selector: + kubernetes.io/arch: amd64 + +volumes: +- name: fedhq-ca-crt + config_map: + name: fedhq-ca-crt + default_mode: 420 # same as 644 in octal, or u+w,a+r + optional: false + +steps: + - name: build amd64 + image: quay.io/buildah/stable + privileged: true + volumes: + - name: fedhq-ca-crt + path: /etc/ssl/certs2/ + commands: + - scripts/setupEnvironment.sh + - buildah bud --network host -t "registry.cloud.federationhq.de/imapfilter:latest-amd64" --arch amd64 . + - buildah push --all registry.cloud.federationhq.de/imapfilter:latest-amd64 +--- +kind: pipeline +type: kubernetes +name: build-arm64 +platform: + arch: arm64 +node_selector: + kubernetes.io/arch: arm64 + +volumes: +- name: fedhq-ca-crt + config_map: + name: fedhq-ca-crt + default_mode: 420 # same as 644 in octal, or u+w,a+r + optional: false + +steps: + - name: build arm64 + image: quay.io/buildah/stable + privileged: true + volumes: + - name: fedhq-ca-crt + path: /etc/ssl/certs2/ + commands: + - scripts/setupEnvironment.sh + - buildah bud --network host -t "registry.cloud.federationhq.de/imapfilter:latest-arm64" --arch arm64 . + - buildah push --all registry.cloud.federationhq.de/imapfilter:latest-arm64 +--- +kind: pipeline +type: kubernetes +name: push +node_selector: + kubernetes.io/arch: amd64 + +volumes: +- name: fedhq-ca-crt + config_map: + name: fedhq-ca-crt + default_mode: 420 # same as 644 in octal, or u+w,a+r + optional: false + +steps: + - name: push + image: quay.io/buildah/stable + privileged: true + volumes: + - name: fedhq-ca-crt + path: /etc/ssl/certs2/ + commands: + - scripts/setupEnvironment.sh + - buildah manifest create registry.cloud.federationhq.de/imapfilter:latest registry.cloud.federationhq.de/imapfilter:latest-arm64 registry.cloud.federationhq.de/imapfilter:latest-amd64 + - buildah manifest push registry.cloud.federationhq.de/imapfilter:latest docker://registry.cloud.federationhq.de/imapfilter:latest + - buildah manifest rm registry.cloud.federationhq.de/imapfilter:latest +depends_on: + - build-amd64 + - build-arm64 \ No newline at end of file diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..52cdcc6 --- /dev/null +++ b/Containerfile @@ -0,0 +1,25 @@ +FROM alpine as builder + +RUN apk update && apk add --no-cache git openssl openssl-dev make lua5.1 lua-dev pcre2 pcre2-dev alpine-sdk + +WORKDIR /src + +RUN git clone https://github.com/lefcha/imapfilter.git + +RUN cd imapfilter; make all + +FROM alpine +# + +# Ensure we have imapfilter dependencies +RUN apk update && apk add --no-cache tini bash ca-certificates openssl lua5.1 pcre2 + +RUN mkdir -p /usr/local/share/imapfilter + +COPY --from=builder /src/imapfilter/src/imapfilter /usr/local/bin/ +COPY --from=builder /src/imapfilter/src/*.lua /usr/local/share/imapfilter/ +ADD scripts/entryPoint.sh /entryPoint.sh + +RUN chmod +x /entryPoint.sh + +ENTRYPOINT ["/sbin/tini", "--", "/entryPoint.sh"] \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..38dfa66 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) [2024] [Dominik Meyer] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..49d2068 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# ImapFilter Container Image + +This repository contains the Containerfile and associated scripts for a container image that runs [imapfilter](https://github.com/lefcha/imapfilter). + +The container is based on alpine linux to keep it small. + +## Author + +- Dominik Meyer + + +## Prerequisites + +- Buildah + +## Usage + +### Building the Container Image + +You can build the container image using the following command: + +\```bash +buildah bud -t imapfilter:latest . +\``` + +### Running the Container + +You can create and run a container from this image with the following command: + +\```bash +podman run -d --name imapfilter imapfilter:latest +\``` + +### Pushing the Container Image to a Registry + +With Buildah: + +\```bash +buildah push imapfilter:latest docker:////imapfilter:latest +\``` + +Replace `` with the name of your Docker registry and `` with your username on that registry. + +## Configuration + +T.b.d. + +## License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. diff --git a/scripts/entryPoint.sh b/scripts/entryPoint.sh new file mode 100755 index 0000000..4b3a30e --- /dev/null +++ b/scripts/entryPoint.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +export IMAPFILTER_HOME=/imapfilter/ + +if [ ! -e ${IMAPFILTER_HOME}/config.lua ]; then + echo "please provide a config.lua from a configmap" + exit 255 +fi + +while [ 1 -eq 1 ]; do + imapfilter -l /dev/stdout -v + sleep 500 +done \ No newline at end of file diff --git a/scripts/setupEnvironment.sh b/scripts/setupEnvironment.sh new file mode 100755 index 0000000..2761ce0 --- /dev/null +++ b/scripts/setupEnvironment.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cp /etc/ssl/certs2/federationHQ-CA.pem /etc/pki/ca-trust/source/anchors/ +update-ca-trust