Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[{docker-compose.yml,docker-compose.*.yml}]
[{docker-compose.yml,docker-compose.*.yml,.github/workflows/*.yml}]
indent_size = 2

[*.md]
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/mailcrypt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Mailcrypt

on:
pull_request:
paths:
- "contrib/userli-dovecot-adapter.lua"
- "docker/dovecot/**"
- "docker-compose.mailcrypt-test.yml"
- "tests/test_mailcrypt.sh"
- "tests/dovecot-api-mock.py"
- ".github/workflows/mailcrypt.yml"
push:
branches:
- main
paths:
- "contrib/userli-dovecot-adapter.lua"
- "docker/dovecot/**"
- "docker-compose.mailcrypt-test.yml"
- "tests/test_mailcrypt.sh"
- "tests/dovecot-api-mock.py"
- ".github/workflows/mailcrypt.yml"

jobs:
mailcrypt:
runs-on: ubuntu-24.04
name: Dovecot Mailcrypt Integration

env:
COMPOSE_FILE: docker-compose.mailcrypt-test.yml

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Start containers
run: docker compose up -d

- name: Wait for Dovecot to be ready
run: |
for i in $(seq 1 30); do
if docker compose exec dovecot doveadm service status imap-login > /dev/null 2>&1; then
echo "Dovecot is ready"
break
fi
echo "Waiting for Dovecot... ($i/30)"
sleep 2
done

- name: Run mailcrypt tests
run: bash tests/mailcrypt_integration.sh

- name: Dovecot logs
if: failure()
run: docker compose logs dovecot

- name: Mock API logs
if: failure()
run: docker compose logs mock-api

- name: Stop containers
if: always()
run: docker compose down -v
55 changes: 55 additions & 0 deletions docker-compose.mailcrypt-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
# Minimal compose file for mailcrypt integration tests.
# Starts only dovecot, a mock Userli API, and a tools container.
#
# Usage:
# docker compose -f docker-compose.mailcrypt-test.yml up -d
# bash tests/mailcrypt_integration.sh
# docker compose -f docker-compose.mailcrypt-test.yml down -v

services:
dovecot:
depends_on:
mock-api:
condition: service_healthy
image: dovecot/dovecot:latest
environment:
MAIL_CRYPT: 2
USERLI_HOST: mock-api
USERLI_API_ACCESS_TOKEN: 727eb7d3ad310bc510f5fa17c223572c
DOVECOT_LUA_INSECURE: "true"
ports:
- "1143:31143"
volumes:
- vmail:/srv/vmail
- ./docker/dovecot/dovecot.conf:/etc/dovecot/dovecot.conf:ro
- ./docker/dovecot/conf.d:/etc/dovecot/conf.d:ro
- ./contrib/userli-dovecot-adapter.lua:/usr/local/bin/userli-dovecot-adapter.lua:ro

mock-api:
image: docker.io/python:3-alpine
working_dir: /app
command: python dovecot-api-mock.py 80
volumes:
- ./tests/dovecot-api-mock.py:/app/dovecot-api-mock.py:ro
healthcheck:
test:
[
"CMD",
"python",
"-c",
"import urllib.request as u; u.urlopen(u.Request('http://localhost/api/dovecot/status', headers={'Authorization': 'Bearer 727eb7d3ad310bc510f5fa17c223572c'}))",
]
interval: 2s
timeout: 3s
retries: 5

tools:
image: busybox:stable
profiles:
- tools
volumes:
- vmail:/srv/vmail:ro

volumes:
vmail:
24 changes: 18 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@ services:
- userli

dovecot:
build:
context: .
dockerfile: docker/dovecot/Dockerfile
depends_on:
- userli
image: dovecot/dovecot:2.4.2
environment:
MAIL_CRYPT: 2
USERLI_HOST: userli
USERLI_API_ACCESS_TOKEN: 727eb7d3ad310bc510f5fa17c223572c
DOVECOT_LUA_INSECURE: "true"
ports:
- "1143:143"
- "1143:31143"
volumes:
- vmail:/var/vmail
- vmail:/srv/vmail
- ./docker/dovecot/dovecot.conf:/etc/dovecot/dovecot.conf:ro
- ./docker/dovecot/conf.d:/etc/dovecot/conf.d:ro
- ./contrib/userli-dovecot-adapter.lua:/usr/local/bin/userli-dovecot-adapter.lua:ro
Expand All @@ -96,9 +96,12 @@ services:

roundcube:
image: docker.io/roundcube/roundcubemail:1.6.11-apache
depends_on:
- dovecot
- mailcatcher
environment:
ROUNDCUBEMAIL_DEFAULT_HOST: dovecot
ROUNDCUBEMAIL_DEFAULT_PORT: 143
ROUNDCUBEMAIL_DEFAULT_PORT: 31143
ROUNDCUBEMAIL_SMTP_SERVER: smtp://mailcatcher
ROUNDCUBEMAIL_SMTP_PORT: 1025
ROUNDCUBEMAIL_USERNAME_DOMAIN: example.org
Expand Down Expand Up @@ -127,6 +130,15 @@ services:
networks:
- userli

tools:
image: busybox:stable
profiles:
- tools
volumes:
- vmail:/srv/vmail:ro
networks:
- userli

networks:
userli:

Expand Down
42 changes: 0 additions & 42 deletions docker/dovecot/Dockerfile

This file was deleted.

41 changes: 25 additions & 16 deletions docker/dovecot/dovecot.conf
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
## You should mount /etc/dovecot if you want to
## manage this file
## Userli Dovecot configuration
## Mounted into the official dovecot/dovecot Docker image

dovecot_config_version = 2.4.0
dovecot_storage_version = 2.4.0
dovecot_config_version = 2.4.2
dovecot_storage_version = 2.4.2

mail_home = /var/vmail/%{user|username|lower}
default_login_user = vmail
default_internal_user = vmail
default_internal_group = vmail

mail_home = /srv/vmail/%{user|username|lower}
mail_driver = sdbox
mail_path = ~/Mail
mail_uid = 5000
mail_gid = 5000
mail_uid = vmail
mail_gid = vmail

mail_plugins {
mail_crypt = yes
Expand All @@ -17,12 +21,13 @@ crypt_write_algorithm =

protocols = imap pop3 submission sieve lmtp

first_valid_uid = 5000
last_valid_uid = 5000
first_valid_uid = 1000
last_valid_uid = 1000

ssl = yes
ssl_server_cert_file = cert.pem
ssl_server_key_file = key.pem
ssl_server {
cert_file = /etc/dovecot/ssl/tls.crt
key_file = /etc/dovecot/ssl/tls.key
}

namespace inbox {
inbox = yes
Expand All @@ -40,13 +45,17 @@ namespace inbox {

service lmtp {
inet_listener lmtp {
port = 24
port = 31024
}
}

service imap-login {
process_min_avail = 1
client_limit = 1000

inet_listener imap {
port = 31143
}
}

service pop3-login {
Expand All @@ -66,9 +75,9 @@ service managesieve-login {

listen = *

log_path=/dev/stdout
info_log_path=/dev/stdout
debug_log_path=/dev/stdout
log_path = /dev/stdout
info_log_path = /dev/stdout
debug_log_path = /dev/stdout

verbose_proctitle = yes

Expand Down
Loading