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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ RUN apk --no-cache add \
php84-mbstring \
php84-opcache \
php84-openssl \
php84-pcntl \
php84-pdo \
php84-pdo_mysql \
php84-phar \
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ___
* [Generate DKIM private/public keypair](#generate-dkim-privatepublic-keypair)
* [Generate GPG key](#generate-gpg-key)
* [Define additional env vars](#define-additional-env-vars)
* [Background jobs](#background-jobs)
* [Override Postfix main configuration](#override-postfix-main-configuration)
* [Spamhaus DQS configuration](#spamhaus-dqs-configuration)
* [Contributing](#contributing)
Expand Down Expand Up @@ -102,6 +103,7 @@ linux/arm64
* `APP_KEY`: Application key for encrypter service. You can generate one through `anonaddy key:generate --show` or `echo "base64:$(openssl rand -base64 32)"`. **required**
* `APP_DEBUG`: Enables or disables debug mode, used to troubleshoot issues (default `false`)
* `APP_URL`: The URL of your installation
* `QUEUE_CONNECTION`: Job execution mode, `sync` or `redis` (default `sync`). See [Background jobs](#background-jobs) for Redis queue setup.
* `ANONADDY_RETURN_PATH`: Return-path header for outbound emails
* `ANONADDY_ADMIN_USERNAME`: If set this value will be used and allow you to receive forwarded emails at the root domain
* `ANONADDY_ENABLE_REGISTRATION`: If set to false this will prevent new users from registering on the site (default `true`)
Expand Down Expand Up @@ -306,6 +308,25 @@ Keys will be stored in `/data/.gnupg` folder.
You can define additional environment variables that will be used by the app
by creating a file named `.env` in `/data`.

### Background jobs

With `QUEUE_CONNECTION=redis`, all queued application jobs, including email
delivery and notifications, run in the background. The worker uses the configured
Redis server and queue. Other queue connections require an externally managed
worker.

The worker allows three attempts with a five-second retry delay and a 60-second
timeout. Job-specific retry and timeout settings take precedence. The timeout is
shorter than the application's 90-second Redis retry interval.

The Compose examples enable Redis append-only persistence in `./redis`. When
enabling queues, set `S6_SERVICES_GRACETIME=65000` and `stop_grace_period: 90s`
on the `addy` service so the worker can finish its current job during shutdown.

Drain pending jobs before switching back to `sync`, since that mode does
not start a worker. Failed jobs can be inspected with `anonaddy queue:failed` and
retried with `anonaddy queue:retry <id>`.

### Override Postfix main configuration

In some cases you may want to override the default Postfix main configuration
Expand Down
3 changes: 3 additions & 0 deletions examples/compose/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ services:
redis:
image: redis:8-alpine
container_name: addy_redis
command: ["redis-server", "--appendonly", "yes"]
volumes:
- "./redis:/data"
restart: always

addy:
Expand Down
3 changes: 3 additions & 0 deletions examples/nginx/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ services:
redis:
image: redis:8-alpine
container_name: addy_redis
command: ["redis-server", "--appendonly", "yes"]
volumes:
- "./redis:/data"
restart: always

addy:
Expand Down
3 changes: 3 additions & 0 deletions examples/rspamd/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ services:
redis:
image: redis:8-alpine
container_name: addy_redis
command: ["redis-server", "--appendonly", "yes"]
volumes:
- "./redis:/data"
restart: always

addy:
Expand Down
3 changes: 3 additions & 0 deletions examples/traefik/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ services:
redis:
image: redis:8-alpine
container_name: addy_redis
command: ["redis-server", "--appendonly", "yes"]
volumes:
- "./redis:/data"
restart: always

addy:
Expand Down
1 change: 1 addition & 0 deletions rootfs/etc/cont-init.d/00-env
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ APP_NAME=${APP_NAME:-addy.io}
#APP_KEY=${APP_KEY:-base64:Gh8/RWtNfXTmB09pj6iEflt/L6oqDf9ZxXIh4I9MS7A=}
APP_DEBUG=${APP_DEBUG:-false}
APP_URL=${APP_URL:-http://localhost}
QUEUE_CONNECTION=${QUEUE_CONNECTION:-sync}

#DB_HOST=${DB_HOST:-localhost}
DB_PORT=${DB_PORT:-3306}
Expand Down
2 changes: 1 addition & 1 deletion rootfs/etc/cont-init.d/13-config-anonaddy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ echo "Creating env file"
printf '\n'
dotenv_entry "BROADCAST_DRIVER" "log"
dotenv_entry "CACHE_DRIVER" "file"
dotenv_entry "QUEUE_CONNECTION" "sync"
dotenv_entry "QUEUE_CONNECTION" "$QUEUE_CONNECTION"
dotenv_entry "SESSION_DRIVER" "file"
dotenv_entry "SESSION_LIFETIME" "120"

Expand Down
19 changes: 19 additions & 0 deletions rootfs/etc/cont-init.d/50-svc-main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,22 @@ s6-setuidgid ${PUID}:${PGID}
php-fpm84 -F
EOL
chmod +x /etc/services.d/php-fpm/run

# Read the cached configuration after /data/.env overrides have been applied.
queue_connection=$(php -r '$config = require "/var/www/anonaddy/bootstrap/cache/config.php"; echo $config["queue"]["default"];')

# Remove a previously generated service when restarting with another connection.
rm -rf /etc/services.d/queue
if [ "$queue_connection" = "redis" ]; then
echo "Creating Redis queue worker"
mkdir -p /etc/services.d/queue
cat > /etc/services.d/queue/run <<EOL
#!/usr/bin/execlineb -P
with-contenv
s6-setuidgid ${PUID}:${PGID}
php /var/www/anonaddy/artisan queue:work redis --sleep=3 --tries=3 --backoff=5 --timeout=60 --no-interaction --no-ansi
EOL
chmod +x /etc/services.d/queue/run
else
echo "INFO: Redis queue worker disabled (connection: ${queue_connection})."
fi
Loading