mirror of
https://github.com/DoTheEvo/selfhosted-apps-docker.git
synced 2026-07-03 14:06:40 +02:00
Mail-Archiver
guide-by-example
Purpose & Overview
IMAP email archiving system with web gui managment.
Written in C# for backend and postgres for database.
A very new project but looks super promising.
Files and directory structure
/home/
└── ~/
└── docker/
└── mail-archiver/
├── 🗁 mailarchiver_database/
├── 🗋 .env
└── 🗋 compose.yml
mailarchiver_database- contains the database data, including all emails and attachments.env- the file containing environment variables for docker composecompose.yml- the compose file that defines how to run the containers
Only the two files are required.
The directories are created on the first run.
Compose
Some changes from the official compose.
- env variables are moved to the
.envfile - reverse proxy is expected so the ports are only exposed(documented), not mapped to the host
- hostname and container name are added
- renamed services to have more clear name
which required to also change the connection string variable, replacing hostpostgreswithmailarchiver-db - changed bind mount folder name
- network is set
compose.yml
services:
mailarchiver-app:
image: s1t5/mailarchiver:latest
container_name: mailarchiver-app
hostname: mailarchiver-app
restart: unless-stopped
env_file: .env
expose:
- "5000"
depends_on:
mailarchiver-db:
condition: service_healthy
mailarchiver-db:
image: postgres:17-alpine
container_name: mailarchiver-db
hostname: mailarchiver-db
restart: unless-stopped
env_file: .env
expose:
- "5432"
volumes:
- ./mailarchiver_database:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U mailuser -d MailArchiver"]
interval: 300s
timeout: 10s
retries: 3
start_period: 30s
networks:
default:
name: $DOCKER_MY_NETWORK
external: true
.env
# GENERAL
DOCKER_MY_NETWORK=caddy_net
TZ=Europe/Bratislava
# Database Connection
ConnectionStrings__DefaultConnection=Host=mailarchiver-db;Database=MailArchiver;Username=mailuser;Password=masterkey;
# Authentication Settings
Authentication__Enabled=true
Authentication__Username=admin
Authentication__Password=secure123!
Authentication__SessionTimeoutMinutes=60
Authentication__CookieName=MailArchiverAuth
# MailSync Settings
MailSync__IntervalMinutes=15
MailSync__TimeoutMinutes=60
MailSync__ConnectionTimeoutSeconds=180
MailSync__CommandTimeoutSeconds=300
# BatchRestore Settings
BatchRestore__AsyncThreshold=50
BatchRestore__MaxSyncEmails=150
BatchRestore__MaxAsyncEmails=50000
BatchRestore__SessionTimeoutMinutes=30
BatchRestore__DefaultBatchSize=50
# Npgsql Settings
Npgsql__CommandTimeout=600
# POSTGRES
POSTGRES_DB=MailArchiver
POSTGRES_USER=mailuser
POSTGRES_PASSWORD=masterkey
All containers must be on the same network.
Which is named in the .env file.
If one does not exist yet: docker network create caddy_net
Reverse proxy
Caddy v2 is used, details
here.
Caddyfile
mailarchiver.{$MY_DOMAIN} {
reverse_proxy mailarchiver-app:5000
}
First run
Login with the credentials set in the .env file
gmail
- 2factorAuth needs to be fulyl enabled and set
- https://myaccount.google.com/apppasswords
create app password
Trouble shooting
Update
Manual image update:
docker-compose pulldocker-compose up -ddocker image prune
It is strongly recommended to now add current tags to the images in the compose.
Tags will allow you to easily return to a working state if an update goes wrong.