Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Improve verbosity config in aio image (#1098)

Leendert de Borste2fc9878b0d1
diff --git a/dockerfiles/Dockerfile.server.allinone b/dockerfiles/Dockerfile.server.allinone
index d341aad41..22438fe90 100644
--- a/dockerfiles/Dockerfile.server.allinone
+++ b/dockerfiles/Dockerfile.server.allinone
@@ -143,10 +143,12 @@ RUN mkdir -p /etc/s6-overlay/s6-rc.d/user/contents.d && \
touch /etc/s6-overlay/s6-rc.d/user/contents.d/nginx
# Set environment variables for s6-overlay
+# ALIASVAULT_VERBOSITY: 0=minimal (default), 1=normal, 2=verbose
ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_VERBOSITY=0 \
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
- S6_KILL_GRACETIME=30000
+ S6_KILL_GRACETIME=30000 \
+ ALIASVAULT_VERBOSITY=0
# Expose ports
EXPOSE 80 443 25 587
diff --git a/dockerfiles/s6-scripts/admin/run b/dockerfiles/s6-scripts/admin/run
index 1d932f568..d6eac79b8 100644
--- a/dockerfiles/s6-scripts/admin/run
+++ b/dockerfiles/s6-scripts/admin/run
@@ -2,14 +2,22 @@
cd /app/admin
+# Get verbosity level (0=minimal, 1=normal, 2=verbose)
+VERBOSITY="${ALIASVAULT_VERBOSITY:-0}"
+
# Read PostgreSQL password from file
POSTGRES_PASSWORD=$(cat /secrets/postgres_password)
# Wait for PostgreSQL to be ready
-echo "[admin] Waiting for PostgreSQL to be ready..."
+if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[admin] Waiting for PostgreSQL to be ready..."
+fi
+
for i in {1..30}; do
if PGPASSWORD="$POSTGRES_PASSWORD" /usr/lib/postgresql/16/bin/psql -h localhost -U aliasvault -d aliasvault -c "SELECT 1;" >/dev/null 2>&1; then
- echo "[admin] PostgreSQL ready, starting Admin..."
+ if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[admin] PostgreSQL ready, starting Admin..."
+ fi
break
fi
if [ $i -eq 30 ]; then
@@ -24,5 +32,20 @@ export ASPNETCORE_URLS="http://0.0.0.0:3002"
export ASPNETCORE_PATHBASE="/admin"
export IP_LOGGING_ENABLED="${IP_LOGGING_ENABLED:-true}"
-echo "[admin] Starting Admin service..."
+# Set .NET logging level based on verbosity
+if [ "$VERBOSITY" -ge 2 ]; then
+ export Logging__LogLevel__Default="Information"
+elif [ "$VERBOSITY" -ge 1 ]; then
+ export Logging__LogLevel__Default="Warning"
+ export Logging__LogLevel__Microsoft__Hosting__Lifetime="Warning"
+else
+ export Logging__LogLevel__Default="Error"
+ export Logging__LogLevel__Microsoft__Hosting__Lifetime="Error"
+ export Logging__LogLevel__Microsoft="Error"
+fi
+
+if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[admin] Starting Admin service..."
+fi
+
exec dotnet AliasVault.Admin.dll
\ No newline at end of file
diff --git a/dockerfiles/s6-scripts/api/run b/dockerfiles/s6-scripts/api/run
index 398b050f3..c3abec47b 100644
--- a/dockerfiles/s6-scripts/api/run
+++ b/dockerfiles/s6-scripts/api/run
@@ -2,14 +2,22 @@
cd /app/api
+# Get verbosity level (0=minimal, 1=normal, 2=verbose)
+VERBOSITY="${ALIASVAULT_VERBOSITY:-0}"
+
# Read PostgreSQL password from file
POSTGRES_PASSWORD=$(cat /secrets/postgres_password)
# Wait for PostgreSQL to be ready
-echo "[api] Waiting for PostgreSQL to be ready..."
+if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[api] Waiting for PostgreSQL to be ready..."
+fi
+
for i in {1..30}; do
if PGPASSWORD="$POSTGRES_PASSWORD" /usr/lib/postgresql/16/bin/psql -h localhost -U aliasvault -d aliasvault -c "SELECT 1;" >/dev/null 2>&1; then
- echo "[api] PostgreSQL ready, starting API..."
+ if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[api] PostgreSQL ready, starting API..."
+ fi
break
fi
if [ $i -eq 30 ]; then
@@ -26,5 +34,20 @@ export PRIVATE_EMAIL_DOMAINS="${PRIVATE_EMAIL_DOMAINS:-}"
export PUBLIC_REGISTRATION_ENABLED="${PUBLIC_REGISTRATION_ENABLED:-true}"
export IP_LOGGING_ENABLED="${IP_LOGGING_ENABLED:-true}"
-echo "[api] Starting API service..."
+# Set .NET logging level based on verbosity
+if [ "$VERBOSITY" -ge 2 ]; then
+ export Logging__LogLevel__Default="Information"
+elif [ "$VERBOSITY" -ge 1 ]; then
+ export Logging__LogLevel__Default="Warning"
+ export Logging__LogLevel__Microsoft__Hosting__Lifetime="Warning"
+else
+ export Logging__LogLevel__Default="Error"
+ export Logging__LogLevel__Microsoft__Hosting__Lifetime="Error"
+ export Logging__LogLevel__Microsoft="Error"
+fi
+
+if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[api] Starting API service..."
+fi
+
exec dotnet AliasVault.Api.dll
\ No newline at end of file
diff --git a/dockerfiles/s6-scripts/client/run b/dockerfiles/s6-scripts/client/run
index 2cdab1335..aea6c3a75 100644
--- a/dockerfiles/s6-scripts/client/run
+++ b/dockerfiles/s6-scripts/client/run
@@ -1,5 +1,8 @@
#!/command/with-contenv bash
+# Get verbosity level (0=minimal, 1=normal, 2=verbose)
+VERBOSITY="${ALIASVAULT_VERBOSITY:-0}"
+
# Client service entrypoint
DEFAULT_PRIVATE_EMAIL_DOMAINS=""
DEFAULT_SUPPORT_EMAIL=""
@@ -10,10 +13,17 @@ PUBLIC_REGISTRATION_ENABLED=${PUBLIC_REGISTRATION_ENABLED:-true}
mkdir -p /etc/nginx/ssl
if [ ! -f /etc/nginx/ssl/nginx.crt ] || [ ! -f /etc/nginx/ssl/nginx.key ]; then
- openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
- -keyout /etc/nginx/ssl/nginx.key \
- -out /etc/nginx/ssl/nginx.crt \
- -subj "/C=US/ST=State/L=City/O=Organization/CN=localhost" >/dev/null 2>&1
+ if [ "$VERBOSITY" -ge 2 ]; then
+ openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
+ -keyout /etc/nginx/ssl/nginx.key \
+ -out /etc/nginx/ssl/nginx.crt \
+ -subj "/C=US/ST=State/L=City/O=Organization/CN=localhost"
+ else
+ openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
+ -keyout /etc/nginx/ssl/nginx.key \
+ -out /etc/nginx/ssl/nginx.crt \
+ -subj "/C=US/ST=State/L=City/O=Organization/CN=localhost" >/dev/null 2>&1
+ fi
chmod 644 /etc/nginx/ssl/nginx.crt
chmod 600 /etc/nginx/ssl/nginx.key
fi
@@ -29,5 +39,18 @@ EOF
sed -i "s|/usr/share/nginx/html|/app/client/wwwroot|g" /app/client/nginx.conf
-echo "[client] Starting Client service (nginx)..."
-exec nginx -c /app/client/nginx.conf -g "daemon off;"
\ No newline at end of file
+if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[client] Starting Client service (nginx)..."
+fi
+
+# Set nginx error log level based on verbosity
+if [ "$VERBOSITY" -ge 2 ]; then
+ # Verbose: info level
+ exec nginx -c /app/client/nginx.conf -g "daemon off; error_log /dev/stderr info;"
+elif [ "$VERBOSITY" -ge 1 ]; then
+ # Normal: warn level
+ exec nginx -c /app/client/nginx.conf -g "daemon off; error_log /dev/stderr warn;"
+else
+ # Minimal: error level only
+ exec nginx -c /app/client/nginx.conf -g "daemon off; error_log /dev/stderr error;"
+fi
\ No newline at end of file
diff --git a/dockerfiles/s6-scripts/init/script b/dockerfiles/s6-scripts/init/script
index 4e644e65a..111dd3896 100644
--- a/dockerfiles/s6-scripts/init/script
+++ b/dockerfiles/s6-scripts/init/script
@@ -3,7 +3,19 @@
# AliasVault Container Initialization Script
# This script runs once at container startup and handles all initialization tasks
-# Print AliasVault header
+# Get verbosity level (0=minimal, 1=normal, 2=verbose)
+VERBOSITY="${ALIASVAULT_VERBOSITY:-0}"
+
+# Helper function for logging based on verbosity
+log() {
+ level=$1
+ shift
+ if [ "$VERBOSITY" -ge "$level" ]; then
+ echo "$@"
+ fi
+}
+
+# Always show header and critical messages (level 0)
echo ""
echo "=================================================="
echo " _ _ _ __ __ _ _ "
@@ -15,42 +27,42 @@ echo ""
echo "=================================================="
echo ""
-echo "[init] Starting AliasVault container initialization..."
+echo "[init] Starting AliasVault..."
echo ""
# Create required directories
-echo "[init] Creating required directories..."
+log 0 "[init] Creating required directories..."
mkdir -p /database/postgres /logs/postgres /certificates /secrets /var/run/postgresql
# Initialize secrets if they don't exist
-echo "[init] Checking and initializing secrets..."
+log 0 "[init] Checking and initializing secrets..."
if [ ! -f /secrets/postgres_password ]; then
- echo "[init] → Generating PostgreSQL password..."
+ log 0 "[init] → Generating PostgreSQL password..."
openssl rand -base64 32 | tr -d "\n" > /secrets/postgres_password
chmod 600 /secrets/postgres_password
else
- echo "[init] → PostgreSQL password already exists"
+ log 0 "[init] ✅ PostgreSQL password already exists "
fi
if [ ! -f /secrets/data_protection_cert_pass ]; then
- echo "[init] → Generating Data Protection Certificate password..."
+ log 0 "[init] → Generating Data Protection Certificate password..."
openssl rand -base64 32 | tr -d "\n" > /secrets/data_protection_cert_pass
chmod 600 /secrets/data_protection_cert_pass
else
- echo "[init] → Data Protection Certificate password already exists"
+ log 0 "[init] ✅ Data Protection Certificate password already exists"
fi
if [ ! -f /secrets/jwt_key ]; then
- echo "[init] → Generating JWT key..."
+ log 0 "[init] → Generating JWT key..."
openssl rand -base64 32 | tr -d "\n" > /secrets/jwt_key
chmod 600 /secrets/jwt_key
else
- echo "[init] → JWT key already exists"
+ log 0 "[init] ✅ JWT key already exists"
fi
if [ ! -f /secrets/admin_password_hash ]; then
- echo "[init] → Generating admin password hash..."
+ log 0 "[init] → Generating admin password hash..."
# Generate a random admin password if not provided
if [ -z "$ADMIN_PASSWORD" ]; then
ADMIN_PASSWORD=$(openssl rand -base64 16 | tr -d "\n")
@@ -58,14 +70,18 @@ if [ ! -f /secrets/admin_password_hash ]; then
echo "[init] ⚠️ Please save this password securely and/or optionally change it after first login!"
fi
# Use the InstallCLI to hash the password and append generation timestamp
- HASH=$(/usr/local/bin/aliasvault-cli/AliasVault.InstallCli hash-password "$ADMIN_PASSWORD")
+ if [ "$VERBOSITY" -ge 2 ]; then
+ HASH=$(/usr/local/bin/aliasvault-cli/AliasVault.InstallCli hash-password "$ADMIN_PASSWORD")
+ else
+ HASH=$(/usr/local/bin/aliasvault-cli/AliasVault.InstallCli hash-password "$ADMIN_PASSWORD" 2>/dev/null)
+ fi
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "${HASH}|${TIMESTAMP}" > /secrets/admin_password_hash
chmod 600 /secrets/admin_password_hash
- echo "[init] → Admin password hash saved to /secrets/admin_password_hash"
+ log 0 "[init] ✅ Admin password hash saved to /secrets/admin_password_hash"
else
- echo "[init] → Admin password hash already exists"
- echo "[init] (to reset the admin password, delete the file ./secrets/admin_password_hash and restart the container)"
+ log 0 "[init] ✅ Admin password hash already exists"
+ log 0 "[init] (to reset the admin password, delete the file ./secrets/admin_password_hash and restart the container)"
fi
# Read PostgreSQL password for database initialization
@@ -74,28 +90,36 @@ export PGDATA="/database/postgres"
# Initialize PostgreSQL if needed
if [ ! -d "$PGDATA/base" ]; then
- echo ""
- echo "[init] PostgreSQL database not found, initializing..."
+ log 0 ""
+ log 0 "[init] PostgreSQL database not found, initializing..."
# Set proper permissions
chown -R postgres:postgres /database/postgres /logs/postgres /var/run/postgresql
chmod 700 /database/postgres
# Initialize database as postgres user
- echo "[init] → Running initdb..."
- su - postgres -c "/usr/lib/postgresql/16/bin/initdb -D $PGDATA --locale=en_US.UTF-8 --encoding=UTF8" > /logs/postgres/initdb.log 2>&1
+ log 1 "[init] → Running initdb..."
+ if [ "$VERBOSITY" -ge 2 ]; then
+ su - postgres -c "/usr/lib/postgresql/16/bin/initdb -D $PGDATA --locale=en_US.UTF-8 --encoding=UTF8" 2>&1 | tee /logs/postgres/initdb.log
+ else
+ su - postgres -c "/usr/lib/postgresql/16/bin/initdb -D $PGDATA --locale=en_US.UTF-8 --encoding=UTF8" > /logs/postgres/initdb.log 2>&1
+ fi
# Configure PostgreSQL
- echo "[init] → Configuring PostgreSQL..."
+ log 0 "[init] → Configuring PostgreSQL..."
echo "host all all 127.0.0.1/32 md5" >> "$PGDATA/pg_hba.conf"
echo "listen_addresses = '127.0.0.1'" >> "$PGDATA/postgresql.conf"
# Start PostgreSQL temporarily to create database and user
- echo "[init] → Starting PostgreSQL temporarily for setup..."
- su - postgres -c "/usr/lib/postgresql/16/bin/pg_ctl -D $PGDATA -l /logs/postgres/postgres.log start"
+ log 0 "[init] → Starting PostgreSQL temporarily for setup..."
+ if [ "$VERBOSITY" -ge 2 ]; then
+ su - postgres -c "/usr/lib/postgresql/16/bin/pg_ctl -D $PGDATA -l /logs/postgres/postgres.log start"
+ else
+ su - postgres -c "/usr/lib/postgresql/16/bin/pg_ctl -D $PGDATA -l /logs/postgres/postgres.log start" >/dev/null 2>&1
+ fi
# Wait for PostgreSQL to be ready
- echo "[init] → Waiting for PostgreSQL to be ready..."
+ log 0 "[init] → Waiting for PostgreSQL to be ready..."
i=1
while [ $i -le 30 ]; do
if su - postgres -c "/usr/lib/postgresql/16/bin/psql -c 'SELECT 1;'" >/dev/null 2>&1; then
@@ -106,19 +130,29 @@ if [ ! -d "$PGDATA/base" ]; then
done
# Create database and user
- echo "[init] → Creating AliasVault database and user..."
- su - postgres -c "/usr/lib/postgresql/16/bin/psql -c \"CREATE USER aliasvault WITH PASSWORD '$POSTGRES_PASSWORD'\""
- su - postgres -c "/usr/lib/postgresql/16/bin/psql -c \"CREATE DATABASE aliasvault OWNER aliasvault;\""
- su - postgres -c "/usr/lib/postgresql/16/bin/psql -c \"GRANT ALL PRIVILEGES ON DATABASE aliasvault TO aliasvault;\""
+ log 0 "[init] → Creating AliasVault database and user..."
+ if [ "$VERBOSITY" -ge 2 ]; then
+ su - postgres -c "/usr/lib/postgresql/16/bin/psql -c \"CREATE USER aliasvault WITH PASSWORD '$POSTGRES_PASSWORD'\""
+ su - postgres -c "/usr/lib/postgresql/16/bin/psql -c \"CREATE DATABASE aliasvault OWNER aliasvault;\""
+ su - postgres -c "/usr/lib/postgresql/16/bin/psql -c \"GRANT ALL PRIVILEGES ON DATABASE aliasvault TO aliasvault;\""
+ else
+ su - postgres -c "/usr/lib/postgresql/16/bin/psql -c \"CREATE USER aliasvault WITH PASSWORD '$POSTGRES_PASSWORD'\"" >/dev/null 2>&1
+ su - postgres -c "/usr/lib/postgresql/16/bin/psql -c \"CREATE DATABASE aliasvault OWNER aliasvault;\"" >/dev/null 2>&1
+ su - postgres -c "/usr/lib/postgresql/16/bin/psql -c \"GRANT ALL PRIVILEGES ON DATABASE aliasvault TO aliasvault;\"" >/dev/null 2>&1
+ fi
# Stop PostgreSQL
- echo "[init] → Stopping PostgreSQL..."
- su - postgres -c "/usr/lib/postgresql/16/bin/pg_ctl -D $PGDATA stop"
+ log 0 "[init] → Stopping PostgreSQL..."
+ if [ "$VERBOSITY" -ge 2 ]; then
+ su - postgres -c "/usr/lib/postgresql/16/bin/pg_ctl -D $PGDATA stop"
+ else
+ su - postgres -c "/usr/lib/postgresql/16/bin/pg_ctl -D $PGDATA stop" >/dev/null 2>&1
+ fi
sleep 2
- echo "[init] → PostgreSQL initialization complete"
+ log 0 "[init] ✅ PostgreSQL initialization complete"
else
- echo "[init] PostgreSQL database already initialized"
+ log 0 "[init] ✅ PostgreSQL database already initialized"
# Just ensure permissions are correct
chown -R postgres:postgres /database/postgres /logs/postgres /var/run/postgresql
@@ -126,33 +160,38 @@ else
fi
# Future: Database migrations could go here
-# echo "[init] Checking for database migrations..."
+# log 1 "[init] Checking for database migrations..."
# if [ -f /app/migrations/pending ]; then
-# echo "[init] → Running database migrations..."
+# log 1 "[init] → Running database migrations..."
# # Run migration logic here
# fi
# Generate SSL certificates if needed
if [ ! -f /certificates/ssl/cert.pem ] || [ ! -f /certificates/ssl/key.pem ]; then
- echo ""
- echo "[init] Generating SSL certificates..."
+ log 0 ""
+ log 0 "[init] Generating SSL certificates..."
mkdir -p /certificates/ssl
- openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
- -keyout /certificates/ssl/key.pem \
- -out /certificates/ssl/cert.pem \
- -subj "/C=US/ST=State/L=City/O=AliasVault/CN=${HOSTNAME:-localhost}" \
- >/dev/null 2>&1
+ if [ "$VERBOSITY" -ge 2 ]; then
+ openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
+ -keyout /certificates/ssl/key.pem \
+ -out /certificates/ssl/cert.pem \
+ -subj "/C=US/ST=State/L=City/O=AliasVault/CN=${HOSTNAME:-localhost}"
+ else
+ openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
+ -keyout /certificates/ssl/key.pem \
+ -out /certificates/ssl/cert.pem \
+ -subj "/C=US/ST=State/L=City/O=AliasVault/CN=${HOSTNAME:-localhost}" \
+ >/dev/null 2>&1
+ fi
chmod 600 /certificates/ssl/key.pem
chmod 644 /certificates/ssl/cert.pem
- echo "[init] → SSL certificates generated"
+ log 0 "[init] ✅ SSL certificates generated"
else
- echo "[init] SSL certificates already exist"
+ log 0 "[init] ✅ SSL certificates already exist"
fi
echo ""
-echo "[init] ========================================="
-echo "[init] AliasVault initialization complete!"
-echo "[init] ========================================="
+echo "[init] Waiting for all services to be ready... this can take up to 2 minutes..."
echo ""
# Oneshot service exits successfully, dependencies can now start
\ No newline at end of file
diff --git a/dockerfiles/s6-scripts/nginx/run b/dockerfiles/s6-scripts/nginx/run
index a6ddd2044..5adcc5b26 100644
--- a/dockerfiles/s6-scripts/nginx/run
+++ b/dockerfiles/s6-scripts/nginx/run
@@ -1,5 +1,8 @@
#!/command/with-contenv bash
+# Get verbosity level (0=minimal, 1=normal, 2=verbose)
+VERBOSITY="${ALIASVAULT_VERBOSITY:-0}"
+
# Copy certificates to nginx directory (they were created during init)
mkdir -p /etc/nginx/ssl
cp /certificates/ssl/* /etc/nginx/ssl/ 2>/dev/null || true
@@ -17,10 +20,15 @@ ssl_prefer_server_ciphers off;
SSLEOF
# Wait for all services to be ready
-echo "[nginx] Waiting for services to be ready..."
+if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[nginx] Waiting for services to be ready..."
+fi
+
for i in {1..60}; do
if nc -z localhost 3000 && nc -z localhost 3001 && nc -z localhost 3002; then
- echo "[nginx] All services ready, starting reverse proxy..."
+ if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[nginx] All services ready, starting reverse proxy..."
+ fi
break
fi
if [ $i -eq 60 ]; then
@@ -30,5 +38,34 @@ for i in {1..60}; do
sleep 1
done
-echo "[nginx] Starting reverse proxy..."
-exec nginx -g "daemon off;"
\ No newline at end of file
+if [ "$VERBOSITY" -ge 0 ]; then
+ echo "[nginx] ========================================="
+ echo "[nginx] AliasVault is now ready and accessible!"
+ echo "[nginx] ========================================="
+ echo "[nginx]"
+ echo "[nginx] 🌐 Web Access:"
+ echo "[nginx] • HTTPS: https://localhost:443 (or your custom mapped port)"
+ echo "[nginx] • Admin: https://localhost:443/admin (or your custom mapped port)"
+ echo "[nginx]"
+ echo "[nginx] 🔑 Admin Password:"
+ echo "[nginx] • The admin password is stored in the /secrets/admin_password_hash file"
+ echo "[nginx] • To reset the admin password, delete the file and restart the container"
+ echo "[nginx] • The password is also displayed in the admin panel after first login"
+ echo "[nginx]"
+ echo "[nginx] 📧 Email Ports (if email server enabled):"
+ echo "[nginx] • SMTP: port 25 (or your custom mapped port)"
+ echo "[nginx] • SMTP TLS: port 587 (or your custom mapped port)"
+ echo "[nginx]"
+fi
+
+# Set nginx error log level based on verbosity
+if [ "$VERBOSITY" -ge 2 ]; then
+ # Verbose: info level
+ exec nginx -g "daemon off; error_log /dev/stderr info;"
+elif [ "$VERBOSITY" -ge 1 ]; then
+ # Normal: warn level
+ exec nginx -g "daemon off; error_log /dev/stderr warn;"
+else
+ # Minimal: error level only
+ exec nginx -g "daemon off; error_log /dev/stderr error;"
+fi
\ No newline at end of file
diff --git a/dockerfiles/s6-scripts/postgres/run b/dockerfiles/s6-scripts/postgres/run
index 6f81470a0..d9a64d425 100644
--- a/dockerfiles/s6-scripts/postgres/run
+++ b/dockerfiles/s6-scripts/postgres/run
@@ -4,7 +4,19 @@
export PATH="/usr/lib/postgresql/16/bin:$PATH"
export PGDATA="/database/postgres"
-echo "[postgres] Starting PostgreSQL server..."
+# Get verbosity level (0=minimal, 1=normal, 2=verbose)
+VERBOSITY="${ALIASVAULT_VERBOSITY:-0}"
-# Run PostgreSQL as postgres user
-exec s6-setuidgid postgres /usr/lib/postgresql/16/bin/postgres -D "$PGDATA"
\ No newline at end of file
+# Only show startup message at verbosity level 1+
+if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[postgres] Starting PostgreSQL server..."
+fi
+
+# Run PostgreSQL as postgres user with appropriate logging
+if [ "$VERBOSITY" -ge 2 ]; then
+ # Verbose: Show all PostgreSQL logs
+ exec s6-setuidgid postgres /usr/lib/postgresql/16/bin/postgres -D "$PGDATA"
+else
+ # Minimal/Normal: Redirect logs to file
+ exec s6-setuidgid postgres /usr/lib/postgresql/16/bin/postgres -D "$PGDATA" 2>/logs/postgres/postgres.log
+fi
\ No newline at end of file
diff --git a/dockerfiles/s6-scripts/smtp/run b/dockerfiles/s6-scripts/smtp/run
index 8e38822c8..73059bc1d 100644
--- a/dockerfiles/s6-scripts/smtp/run
+++ b/dockerfiles/s6-scripts/smtp/run
@@ -2,14 +2,22 @@
cd /app/smtp
+# Get verbosity level (0=minimal, 1=normal, 2=verbose)
+VERBOSITY="${ALIASVAULT_VERBOSITY:-0}"
+
# Read PostgreSQL password from file
POSTGRES_PASSWORD=$(cat /secrets/postgres_password)
# Wait for PostgreSQL to be ready
-echo "[smtp] Waiting for PostgreSQL to be ready..."
+if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[smtp] Waiting for PostgreSQL to be ready..."
+fi
+
for i in {1..30}; do
if PGPASSWORD="$POSTGRES_PASSWORD" /usr/lib/postgresql/16/bin/psql -h localhost -U aliasvault -d aliasvault -c "SELECT 1;" >/dev/null 2>&1; then
- echo "[smtp] PostgreSQL ready, starting SMTP..."
+ if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[smtp] PostgreSQL ready, starting SMTP..."
+ fi
break
fi
if [ $i -eq 30 ]; then
@@ -23,5 +31,20 @@ export ConnectionStrings__AliasServerDbContext="Host=localhost;Database=aliasvau
export PRIVATE_EMAIL_DOMAINS="${PRIVATE_EMAIL_DOMAINS:-}"
export SMTP_TLS_ENABLED="${SMTP_TLS_ENABLED:-false}"
-echo "[smtp] Starting SMTP service..."
+# Set .NET logging level based on verbosity
+if [ "$VERBOSITY" -ge 2 ]; then
+ export Logging__LogLevel__Default="Information"
+elif [ "$VERBOSITY" -ge 1 ]; then
+ export Logging__LogLevel__Default="Warning"
+ export Logging__LogLevel__Microsoft__Hosting__Lifetime="Warning"
+else
+ export Logging__LogLevel__Default="Error"
+ export Logging__LogLevel__Microsoft__Hosting__Lifetime="Error"
+ export Logging__LogLevel__Microsoft="Error"
+fi
+
+if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[smtp] Starting SMTP service..."
+fi
+
exec dotnet AliasVault.SmtpService.dll
\ No newline at end of file
diff --git a/dockerfiles/s6-scripts/taskrunner/run b/dockerfiles/s6-scripts/taskrunner/run
index d0eb72137..16ef1cb61 100644
--- a/dockerfiles/s6-scripts/taskrunner/run
+++ b/dockerfiles/s6-scripts/taskrunner/run
@@ -2,14 +2,22 @@
cd /app/taskrunner
+# Get verbosity level (0=minimal, 1=normal, 2=verbose)
+VERBOSITY="${ALIASVAULT_VERBOSITY:-0}"
+
# Read PostgreSQL password from file
POSTGRES_PASSWORD=$(cat /secrets/postgres_password)
# Wait for PostgreSQL to be ready
-echo "[taskrunner] Waiting for PostgreSQL to be ready..."
+if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[taskrunner] Waiting for PostgreSQL to be ready..."
+fi
+
for i in {1..30}; do
if PGPASSWORD="$POSTGRES_PASSWORD" /usr/lib/postgresql/16/bin/psql -h localhost -U aliasvault -d aliasvault -c "SELECT 1;" >/dev/null 2>&1; then
- echo "[taskrunner] PostgreSQL ready, starting TaskRunner..."
+ if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[taskrunner] PostgreSQL ready, starting TaskRunner..."
+ fi
break
fi
if [ $i -eq 30 ]; then
@@ -21,5 +29,20 @@ done
export ConnectionStrings__AliasServerDbContext="Host=localhost;Database=aliasvault;Username=aliasvault;Password=$POSTGRES_PASSWORD"
-echo "[taskrunner] Starting TaskRunner service..."
+# Set .NET logging level based on verbosity
+if [ "$VERBOSITY" -ge 2 ]; then
+ export Logging__LogLevel__Default="Information"
+elif [ "$VERBOSITY" -ge 1 ]; then
+ export Logging__LogLevel__Default="Warning"
+ export Logging__LogLevel__Microsoft__Hosting__Lifetime="Warning"
+else
+ export Logging__LogLevel__Default="Error"
+ export Logging__LogLevel__Microsoft__Hosting__Lifetime="Error"
+ export Logging__LogLevel__Microsoft="Error"
+fi
+
+if [ "$VERBOSITY" -ge 1 ]; then
+ echo "[taskrunner] Starting TaskRunner service..."
+fi
+
exec dotnet AliasVault.TaskRunner.dll
\ No newline at end of file