Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update all-in-one Dockerfile to reduce layers (#1148)
Leendert de Borst610d1b465479
diff --git a/dockerfiles/all-in-one/Dockerfile b/dockerfiles/all-in-one/Dockerfileindex 1c9a9ffde..1be305c63 100644--- a/dockerfiles/all-in-one/Dockerfile+++ b/dockerfiles/all-in-one/Dockerfile@@ -1,5 +1,4 @@# Multi-stage build for AliasVault single container deployment-# This creates a single container with all services for NAS/home server deployments# ============================================# Stage 1: Build .NET applications@@ -7,7 +6,9 @@FROM mcr.microsoft.com/dotnet/sdk:9.0 AS dotnet-builder# Install Python (required for WASM compilation)-RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*+RUN apt-get update && \+ apt-get install -y --no-install-recommends python3 python3-pip && \+ rm -rf /var/lib/apt/lists/*WORKDIR /src@@ -15,138 +16,132 @@ WORKDIR /srcCOPY apps/server/ ./apps/server/COPY shared/ ./shared/-# Install required .NET workloads-RUN dotnet workload install wasm-tools--# Build all .NET applications+# Install required .NET workloads and restore packages once for the entire solutionWORKDIR /src/apps/server--# Build API-RUN dotnet publish AliasVault.Api/AliasVault.Api.csproj -c Release -o /app/api--# Build Client (requires wasm-tools workload)-RUN dotnet publish AliasVault.Client/AliasVault.Client.csproj -c Release -o /app/client--# Build Admin-RUN dotnet publish AliasVault.Admin/AliasVault.Admin.csproj -c Release -o /app/admin--# Build SMTP Service-RUN dotnet publish Services/AliasVault.SmtpService/AliasVault.SmtpService.csproj -c Release -o /app/smtp--# Build Task Runner-RUN dotnet publish Services/AliasVault.TaskRunner/AliasVault.TaskRunner.csproj -c Release -o /app/taskrunner--# Build InstallCLI (for admin password hash generation)-RUN dotnet publish Utilities/AliasVault.InstallCli/AliasVault.InstallCli.csproj -c Release -o /app/installcli+RUN dotnet workload install wasm-tools && \+ dotnet restore aliasvault.sln++# Build all applications in parallel where possible+RUN mkdir -p /app/{api,client,admin,smtp,taskrunner,installcli} && \+ # Build projects in parallel (independent projects first)+ dotnet publish AliasVault.Api/AliasVault.Api.csproj \+ -c Release -o /app/api --no-restore & \+ dotnet publish Services/AliasVault.SmtpService/AliasVault.SmtpService.csproj \+ -c Release -o /app/smtp --no-restore & \+ dotnet publish Services/AliasVault.TaskRunner/AliasVault.TaskRunner.csproj \+ -c Release -o /app/taskrunner --no-restore & \+ dotnet publish Utilities/AliasVault.InstallCli/AliasVault.InstallCli.csproj \+ -c Release -o /app/installcli --no-restore & \+ # Wait for the above builds to complete+ wait && \+ # Build remaining projects (Admin and Client can run in parallel)+ dotnet publish AliasVault.Admin/AliasVault.Admin.csproj \+ -c Release -o /app/admin --no-restore & \+ dotnet publish AliasVault.Client/AliasVault.Client.csproj \+ -c Release -o /app/client --no-restore & \+ # Wait for all builds to complete+ wait && \+ # Clean up .NET debug files and unnecessary files+ find /app -name "*.pdb" -delete && \+ find /app -name "*.xml" -not -name "*.deps.json" -delete && \+ find /app -name "*.Development.json" -delete && \+ find /app -name "web.config" -delete# ============================================-# Stage 2: Final runtime image with s6-overlay+# Stage 2: Download s6-overlay separately# ============================================-FROM mcr.microsoft.com/dotnet/aspnet:9.0--# Install PostgreSQL APT repository to get exact version matching postgres:16-alpine-RUN apt-get update && apt-get install -y \- wget \- ca-certificates \- gnupg \- lsb-release \- && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg \- && echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \- && apt-get update--# Install required packages and locales - pin PostgreSQL to version 16-RUN apt-get install -y \- nginx \- postgresql-16 \- postgresql-client-16 \- openssl \- curl \- xz-utils \- netcat-openbsd \- gettext-base \- locales \- && apt-mark hold postgresql-16 postgresql-client-16 \- && rm -rf /var/lib/apt/lists/* \- && useradd -r -s /bin/bash -d /var/lib/postgresql postgres 2>/dev/null || true \- && sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \- && locale-gen--# Install s6-overlay v3+FROM alpine:3.19 AS s6-downloaderARG S6_OVERLAY_VERSION=3.2.0.2-ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp-ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp-RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz \- && tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz \- && rm /tmp/s6-overlay-*.tar.xz--# Create necessary directories-RUN mkdir -p \- /app/api \- /app/client \- /app/admin \- /app/smtp \- /app/taskrunner \- /database \- /certificates/ssl \- /certificates/app \- /logs/postgres \- /etc/nginx/ssl \- /var/run/postgresql \- /var/www/certbot+RUN wget https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz && \+ wget https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz-# Copy built applications from builder stage-COPY --from=dotnet-builder /app/api /app/api-COPY --from=dotnet-builder /app/client /app/client-COPY --from=dotnet-builder /app/admin /app/admin-COPY --from=dotnet-builder /app/smtp /app/smtp-COPY --from=dotnet-builder /app/taskrunner /app/taskrunner--# Copy InstallCLI to /usr/local/bin and make it executable-COPY --from=dotnet-builder /app/installcli /usr/local/bin/aliasvault-cli-RUN chmod +x /usr/local/bin/aliasvault-cli/AliasVault.InstallCli && \- ln -s /usr/local/bin/aliasvault-cli/AliasVault.InstallCli /usr/local/bin/aliasvault-cli.sh--# Copy password reset script and make it executable+# ============================================+# Stage 3: Final runtime image+# ============================================+FROM mcr.microsoft.com/dotnet/aspnet:9.0-bookworm-slim++# Copy s6-overlay from downloader stage+COPY --from=s6-downloader /*.tar.xz /tmp/++# Install everything in one layer with optimizations+RUN apt-get update && \+ apt-get install -y --no-install-recommends \+ wget \+ ca-certificates \+ gnupg \+ lsb-release && \+ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg && \+ echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \+ apt-get update && \+ apt-get install -y --no-install-recommends \+ nginx-light \+ postgresql-16 \+ postgresql-client-16 \+ openssl \+ curl \+ xz-utils \+ netcat-openbsd \+ gettext-base \+ locales && \+ apt-mark hold postgresql-16 postgresql-client-16 && \+ # Create postgres user and configure locale+ useradd -r -s /bin/bash -d /var/lib/postgresql postgres 2>/dev/null || true && \+ sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \+ locale-gen && \+ # Extract s6-overlay+ tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz && \+ tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz && \+ rm /tmp/s6-overlay-*.tar.xz && \+ # Clean up package manager files ONLY (preserve all PostgreSQL files)+ apt-get clean && \+ apt-get autoremove -y && \+ rm -rf /var/lib/apt/lists/* \+ /usr/share/doc/* \+ /usr/share/man/* \+ /usr/share/info/* \+ /var/cache/apt/* && \+ # Create all required directories+ mkdir -p \+ /app/api \+ /app/client \+ /app/admin \+ /app/smtp \+ /app/taskrunner \+ /app/installcli \+ /database \+ /certificates/ssl \+ /certificates/app \+ /logs/postgres \+ /etc/nginx/ssl \+ /var/run/postgresql \+ /var/www/certbot \+ /etc/s6-overlay/s6-rc.d/user/contents.d++# Copy built applications and all configuration files from builder stage+COPY --from=dotnet-builder /app /app++# Copy configuration files and scripts directly to their destinationsCOPY dockerfiles/all-in-one/reset-admin-password.sh /usr/local/bin/reset-admin-password.sh-RUN chmod +x /usr/local/bin/reset-admin-password.sh--# Copy client nginx configuration and ensure wwwroot is accessibleCOPY apps/server/AliasVault.Client/nginx.conf /app/client/nginx.conf--# Copy nginx configuration for single container deploymentCOPY apps/server/nginx.conf /etc/nginx/nginx.confCOPY apps/server/status.html /usr/share/nginx/html/status.html--# Replace upstream server hostnames with "localhost" in nginx.conf-# to accommodate for the single-container setup (for default nginx.conf)-RUN sed -i 's/server client:3000/server localhost:3000/g' /etc/nginx/nginx.conf && \- sed -i 's/server api:3001/server localhost:3001/g' /etc/nginx/nginx.conf && \- sed -i 's/server admin:3002/server localhost:3002/g' /etc/nginx/nginx.conf--# ============================================-# S6 Service Configuration-# ============================================--# Copy s6 service definitionsCOPY dockerfiles/all-in-one/s6-scripts /etc/s6-overlay/s6-rc.d/-# Make all scripts executable (run for longrun services, up for oneshot services, and script files)-RUN find /etc/s6-overlay/s6-rc.d -type f \( -name "run" -o -name "up" -o -name "script" \) -exec chmod +x {} \;--# Enable all services in the default bundle-RUN mkdir -p /etc/s6-overlay/s6-rc.d/user/contents.d && \- touch /etc/s6-overlay/s6-rc.d/user/contents.d/init && \- touch /etc/s6-overlay/s6-rc.d/user/contents.d/postgres && \- touch /etc/s6-overlay/s6-rc.d/user/contents.d/api && \- touch /etc/s6-overlay/s6-rc.d/user/contents.d/client && \- touch /etc/s6-overlay/s6-rc.d/user/contents.d/admin && \- touch /etc/s6-overlay/s6-rc.d/user/contents.d/smtp && \- touch /etc/s6-overlay/s6-rc.d/user/contents.d/taskrunner && \- touch /etc/s6-overlay/s6-rc.d/user/contents.d/nginx && \- touch /etc/s6-overlay/s6-rc.d/user/contents.d/notification--# Set environment variables for s6-overlay-# ALIASVAULT_VERBOSITY: 0=minimal (default), 1=normal, 2=verbose+# Copy InstallCLI to /usr/local/bin and configure everything+RUN cp -r /app/installcli /usr/local/bin/aliasvault-cli && \+ chmod +x /usr/local/bin/aliasvault-cli/AliasVault.InstallCli \+ /usr/local/bin/reset-admin-password.sh && \+ ln -s /usr/local/bin/aliasvault-cli/AliasVault.InstallCli /usr/local/bin/aliasvault-cli.sh && \+ sed -i 's/server client:3000/server localhost:3000/g; \+ s/server api:3001/server localhost:3001/g; \+ s/server admin:3002/server localhost:3002/g' /etc/nginx/nginx.conf && \+ find /etc/s6-overlay/s6-rc.d -type f \( -name "run" -o -name "up" -o -name "script" \) -exec chmod +x {} \; && \+ cd /etc/s6-overlay/s6-rc.d/user/contents.d && \+ touch init postgres api client admin smtp taskrunner nginx notification && \+ # Remove InstallCLI from /app since we copied it to /usr/local/bin+ rm -rf /app/installcli++# Set environment variablesENV ALIASVAULT_VERBOSITY=0 \PUBLIC_REGISTRATION_ENABLED=true \IP_LOGGING_ENABLED=true \@@ -159,15 +154,8 @@ ENV ALIASVAULT_VERBOSITY=0 \S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \S6_VERBOSITY=0-# Expose portsEXPOSE 80 443 25 587--# Volumes for persistent dataVOLUME ["/database", "/certificates", "/logs", "/secrets"]--# Health checkHEALTHCHECK --interval=30s --timeout=10s --start-period=90s --retries=3 \CMD curl -f -k https://localhost/api || exit 1--# Set s6-overlay as entrypointENTRYPOINT ["/init"]\ No newline at end of filediff --git a/dockerfiles/all-in-one/README.md b/dockerfiles/all-in-one/README.mdnew file mode 100644index 000000000..a22b570d0--- /dev/null+++ b/dockerfiles/all-in-one/README.md@@ -0,0 +1,43 @@+# All-in-One Docker Image++This folder contains a Dockerfile that bundles all AliasVault services into a single container. This all-in-one docker image is published to Docker registries as `aliasvault/aliasvault`, where the multi-docker container images are published as their individual parts like `aliasvault/client`, `aliasvault/api`, `aliasvault/postgres` etc.++### Quick Start - Build and Run Locally++#### 1. Build the Image++```bash+# Build the all-in-one image (from repo root)+docker build -f dockerfiles/all-in-one/Dockerfile -t aliasvault-allinone:local .+```++#### 2. Run the Container++```bash+# Basic run+docker run -d \+ --name aliasvault \+ -p 80:80 \+ -p 443:443 \+ -v ./database:/database \+ -v ./certificates:/certificates \+ -v ./logs:/logs \+ -v ./secrets:/secrets \+ aliasvault-allinone:local+```++#### 3. Access Services++- **Client**: http://localhost+- **Admin**: http://localhost/admin+- **API**: http://localhost/api++### Test & Debug++```bash+# View container logs+docker logs aliasvault++# Access container shell+docker exec -it aliasvault /bin/bash+```