ADD: initial commit
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Dominik Meyer 2024-01-09 22:01:54 +01:00
commit aea097240e
Signed by: byterazor
GPG Key ID: EABDA0FD5981BC97
6 changed files with 194 additions and 0 deletions

82
.drone.yml Normal file
View File

@ -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

25
Containerfile Normal file
View File

@ -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"]

21
LICENSE Normal file
View File

@ -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.

50
README.md Normal file
View File

@ -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 <dmeyer@federationhq.de>
## 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://<registry>/<username>/imapfilter:latest
\```
Replace `<registry>` with the name of your Docker registry and `<username>` 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.

13
scripts/entryPoint.sh Executable file
View File

@ -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

3
scripts/setupEnvironment.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
cp /etc/ssl/certs2/federationHQ-CA.pem /etc/pki/ca-trust/source/anchors/
update-ca-trust