Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.git
.github
data/
logs/
config/
*.md
*.sample
man/
__pycache__
*.pyc
.dockerignore
docker-compose.yml
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
pip install -r requirements-all.txt
pip install flake8

- name: Lint with flake8
run: flake8 NotiMail.py --max-line-length=120 --count --show-source --statistics
43 changes: 43 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docker

on:
push:
branches: [main]
tags: ["v*"]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4

- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha

- uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.11-alpine

WORKDIR /app

RUN apk add --no-cache su-exec

COPY requirements-all.txt requirements.txt ./
RUN pip install --no-cache-dir -r requirements-all.txt

RUN adduser -D -u 1000 notimail

COPY NotiMail.py entrypoint.sh ./
RUN chmod +x entrypoint.sh

RUN mkdir -p /app/config /app/data /app/logs \
&& chown -R notimail:notimail /app

VOLUME ["/app/config", "/app/data", "/app/logs"]

HEALTHCHECK --interval=60s --timeout=5s --start-period=10s --retries=3 \
CMD pgrep -f "python NotiMail.py" > /dev/null || exit 1

ENTRYPOINT ["/app/entrypoint.sh"]
89 changes: 89 additions & 0 deletions config/config.ini.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[GENERAL]
LogFileLocation = /app/logs/notimail.log
DataBaseLocation = /app/data/processed_emails.db
#LogRotationType can be "size" or "time"
LogRotationType = size
#LogRotationSize - Only if size is selected - default is 10 MB
LogRotationSize = 10485760
#LogRotationInterval - Only if time is selected - in days
LogRotationInterval = 7
LogBackupCount = 5

# API Key used to access private information
#APIKey = YouApiKeyHERE!

# Prometheus configuration won't be enabled if not specified or if the required libraries are not present.
#PrometheusHost = 0.0.0.0
#PrometheusPort = 8000

# API Flask Interface won't be enabled if not specified or if the required libraries are not present.
#FlaskHost = 0.0.0.0
#FlaskPort = 8080

[EMAIL:account1]
EmailUser = your@address.com
EmailPass = YourPassword
Host = mail.example.com
#Folders = inbox, sent

# Uncomment and configure the following sections for account-specific notification providers

#[NTFY:account1]
#Url1 = https://ntfy.sh/TOPIC1
#Token1 = Optional token to send notifications to protected topics
#Url2 = https://ntfy.sh/TOPIC2
#Token2 = Optional token to send notifications to protected topics

#[PUSHOVER:account1]
#ApiToken = YOUR_PUSHOVER_API_TOKEN
#UserKey = YOUR_PUSHOVER_USER_KEY

#[GOTIFY:account1]
#Url = https://gotify.example.com/message
#Token = your_gotify_token

#[APPRISE:account1]
#urls = pover://user@token, discord://webhook_id/webhook_token

#[EMAIL:account2]
#EmailUser = your@address.com
#EmailPass = YourPassword
#Host = mail.server.com
#Folders = inbox, sent

# Uncomment and configure the following sections for account-specific notification providers

#[NTFY:account2]
#Url1 = https://ntfy.sh/TOPIC3
#Token1 = Optional token
#Url2 = https://ntfy.sh/TOPIC4
#Token2 = Optional token

#[PUSHOVER:account2]
#ApiToken = YOUR_PUSHOVER_API_TOKEN
#UserKey = YOUR_PUSHOVER_USER_KEY

#[GOTIFY:account2]
#Url = https://gotify.example.com/message
#Token = your_gotify_token

#[APPRISE:account2]
#urls = pover://user@token, discord://webhook_id/webhook_token

# Global notification providers
# If no account-specific notification providers are defined, these will be used - please, set at least one notification provider

[NTFY]
Url1 = https://ntfy.example.com/global_topic
Token1 = Optional global token

#[PUSHOVER]
#ApiToken = YOUR_GLOBAL_PUSHOVER_API_TOKEN
#UserKey = YOUR_GLOBAL_PUSHOVER_USER_KEY

#[GOTIFY]
#Url = https://gotify.example.com/message
#Token = your_global_gotify_token

#[APPRISE]
#urls = pover://user@token, discord://webhook_id/webhook_token
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
notimail:
image: ghcr.io/pepper3k/notimail:main
# To build locally instead, comment out 'image' and uncomment 'build':
# build: .
container_name: notimail
restart: unless-stopped
volumes:
- ./config:/app/config
- ./data:/app/data
- ./logs:/app/logs
ports:
- "8080:8080" # Flask web interface
- "8000:8000" # Prometheus metrics
3 changes: 3 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
chown -R notimail:notimail /app/config /app/data /app/logs
exec su-exec notimail python NotiMail.py -c /app/config/config.ini "$@"