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
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ jobs:
name: ${{ env.CONTAINER_NAME }}
log_check: "ready to handle connections"
timeout: 120
-
name: Check native services
run: |
timeout 60 sh -c 'until docker compose exec -T addy sh -s < s6-services.sh; do sleep 2; done'
working-directory: test
env:
ANONADDY_IMAGE: ${{ env.BUILD_TAG }}
ANONADDY_CONTAINER: ${{ env.CONTAINER_NAME }}
-
name: Logs
if: always()
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG ALPINE_VERSION=3.24

FROM tianon/gosu:latest AS gosu

FROM crazymax/alpine-s6:${ALPINE_VERSION}-2.2.0.3
FROM alpine:${ALPINE_VERSION}
COPY --from=gosu /gosu /usr/local/bin/
RUN apk --no-cache add \
bash \
Expand Down Expand Up @@ -52,6 +52,7 @@ RUN apk --no-cache add \
rspamd \
rspamd-controller \
rspamd-proxy \
s6-overlay \
shadow \
tar \
tzdata \
Expand Down Expand Up @@ -82,7 +83,7 @@ RUN apk --no-cache add \
ARG ANONADDY_VERSION
ENV ANONADDY_VERSION=$ANONADDY_VERSION \
S6_BEHAVIOUR_IF_STAGE2_FAILS="2" \
SOCKLOG_TIMESTAMP_FORMAT="" \
S6_STAGE2_HOOK="/etc/s6-overlay/scripts/init" \
TZ="UTC" \
PUID="1000" \
PGID="1000"
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,9 @@ 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.
enabling queues, set `stop_grace_period: 90s` on the `addy` service so the worker
can finish its current job during shutdown. The native s6-overlay v3 queue
service allows 65 seconds for the worker to stop.

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
Expand Down
13 changes: 0 additions & 13 deletions rootfs/etc/cont-init.d/01-fix-uidgid.sh

This file was deleted.

50 changes: 0 additions & 50 deletions rootfs/etc/cont-init.d/50-svc-main.sh

This file was deleted.

21 changes: 0 additions & 21 deletions rootfs/etc/cont-init.d/61-svc-postfix.sh

This file was deleted.

11 changes: 0 additions & 11 deletions rootfs/etc/cont-init.d/99-clean.sh

This file was deleted.

Empty file.
8 changes: 8 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/cron/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/command/with-contenv sh

log_output=/dev/null
if [ "${LOG_CROND:-true}" = "true" ]; then
log_output=/dev/stdout
fi

exec busybox crond -f -L "$log_output"
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/cron/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
3 changes: 3 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/nginx/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/command/with-contenv sh

exec s6-setuidgid "${PUID}:${PGID}" nginx -g "daemon off;"
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/nginx/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
3 changes: 3 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/php-fpm/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/command/with-contenv sh

exec s6-setuidgid "${PUID}:${PGID}" php-fpm84 -F
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/php-fpm/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
5 changes: 5 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/postfix-logs/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/execlineb -P
with-contenv
s6-setuidgid anonaddy
pipeline -w { s6-log -b "p[postfix]" 1 }
tail -F /data/postfix/mail.log
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/postfix-logs/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
3 changes: 3 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/postfix/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/command/with-contenv sh

exec /usr/sbin/postfix -c /etc/postfix start-fg
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/postfix/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
5 changes: 5 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/queue/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/command/with-contenv sh

cd /var/www/anonaddy || exit 1
exec s6-setuidgid "${PUID}:${PGID}" php artisan queue:work redis \
--sleep=3 --tries=3 --backoff=5 --timeout=60 --no-interaction --no-ansi
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/queue/timeout-down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
65000
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/queue/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
3 changes: 3 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/rspamd/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/command/with-contenv sh

exec /usr/bin/rspamd -i -f -u rspamd -g rspamd
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/rspamd/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
#!/bin/bash
set -e

. $(dirname $0)/00-env
. /etc/s6-overlay/scripts/env

if [[ "$DKIM_ENABLE" = "true" || "$DMARC_ENABLE" = "true" ]]; then
echo >&2 "ERROR: OpenDKIM/OpenDMARC are not supported anymore. Please use Rspamd instead."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
#!/bin/bash
set -e

. $(dirname $0)/00-env
. /etc/s6-overlay/scripts/env

if [ -z "$APP_KEY" ]; then
echo >&2 "ERROR: Either APP_KEY or APP_KEY_FILE must be defined"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=sh
#!/bin/bash
set -e

. $(dirname $0)/00-env
. /etc/s6-overlay/scripts/env

CRONTAB_PATH="/var/spool/cron/crontabs"

CROND_LOG_OUTPUT="/dev/null"
ARTISAN_LOG_OUTPUT=" > /dev/null 2>&1"
if [ "$LOG_CROND" = "true" ]; then
CROND_LOG_OUTPUT="/dev/stdout"
ARTISAN_LOG_OUTPUT=""
fi

Expand All @@ -21,12 +18,3 @@ echo "* * * * * php /var/www/anonaddy/artisan schedule:run --no-ansi --no-intera
# Fix perms
echo "Fixing crontabs permissions..."
chmod -R 0644 ${CRONTAB_PATH}

# Create service
mkdir -p /etc/services.d/cron
cat > /etc/services.d/cron/run <<EOL
#!/usr/bin/execlineb -P
with-contenv
exec busybox crond -f -L ${CROND_LOG_OUTPUT}
EOL
chmod +x /etc/services.d/cron/run
12 changes: 12 additions & 0 deletions rootfs/etc/s6-overlay/scripts/config-main
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e

echo "DB migration"
anonaddy migrate --no-interaction --force

echo "Clear cache"
anonaddy cache:clear --no-interaction
anonaddy config:cache --no-interaction
anonaddy view:cache --no-interaction
anonaddy route:cache --no-interaction
anonaddy queue:restart --no-interaction
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
#!/bin/bash
set -e

. $(dirname $0)/00-env
. /etc/s6-overlay/scripts/env

echo "Setting Nginx configuration"
sed -e "s#@UPLOAD_MAX_SIZE@#$UPLOAD_MAX_SIZE#g" \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
#!/bin/bash
set -e

. $(dirname $0)/00-env
. /etc/s6-overlay/scripts/env

echo "Init PHP extensions"
cp -Rf /tpls/etc/php84/conf.d /etc/php84
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
#!/bin/bash
set -e

. $(dirname $0)/00-env
. /etc/s6-overlay/scripts/env

# Restore original config
cp -f /etc/postfix/master.cf.orig /etc/postfix/master.cf
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
#!/bin/bash
set -e

. $(dirname $0)/00-env
. /etc/s6-overlay/scripts/env

if [ "$RSPAMD_ENABLE" != "true" ]; then
echo "INFO: Rspamd service disabled."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
#!/bin/bash

# From https://github.com/docker-library/mariadb/blob/master/docker-entrypoint.sh#L21-L41
# usage: file_env VAR [DEFAULT]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/with-contenv sh
# shellcheck shell=sh
#!/bin/sh

# Fix access rights to stdout and stderr
chown ${PUID}:${PGID} /proc/self/fd/1 /proc/self/fd/2 || true
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/with-contenv sh
# shellcheck shell=sh
#!/bin/sh
set -e

echo "Fixing perms..."
Expand Down
11 changes: 11 additions & 0 deletions rootfs/etc/s6-overlay/scripts/fix-uidgid
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -e

if [ -n "${PGID}" ] && [ "${PGID}" != "$(id -g anonaddy)" ]; then
echo "Switching to PGID ${PGID}..."
groupmod -o -g "${PGID}" anonaddy
fi
if [ -n "${PUID}" ] && [ "${PUID}" != "$(id -u anonaddy)" ]; then
echo "Switching to PUID ${PUID}..."
usermod -o -u "${PUID}" anonaddy
fi
11 changes: 11 additions & 0 deletions rootfs/etc/s6-overlay/scripts/init
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/command/with-contenv sh
set -e

cd /var/www/anonaddy

# Select services only after Laravel's cached configuration and DKIM keys exist.
for script in fix-logs fix-uidgid fix-perms config config-php config-nginx config-anonaddy config-rspamd config-postfix config-main init-rspamd config-cron; do
"/etc/s6-overlay/scripts/${script}"
done

exec /etc/s6-overlay/scripts/runtime-bundles
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
#!/bin/bash
set -e

. $(dirname $0)/00-env
. /etc/s6-overlay/scripts/env

if [ "$RSPAMD_ENABLE" != "true" ]; then
echo "INFO: Rspamd service disabled."
Expand All @@ -19,12 +18,3 @@ chown rspamd:rspamd /var/run/rspamd

# Fix perms
chown -R rspamd:rspamd /etc/rspamd /var/lib/rspamd

# Create service
mkdir -p /etc/services.d/rspamd
cat >/etc/services.d/rspamd/run <<EOL
#!/usr/bin/execlineb -P
with-contenv
/usr/bin/rspamd -i -f -u rspamd -g rspamd
EOL
chmod +x /etc/services.d/rspamd/run
Loading
Loading