Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update Docker config to bundle new React web app (#2413)
Leendert de Borste15222b26167
diff --git a/.dockerignore b/.dockerignoreindex 6c53a5d22..4308e0850 100644--- a/.dockerignore+++ b/.dockerignore@@ -39,3 +39,9 @@ certificates/# Exclude local built web app index.html, must be generated fresh during Docker build for correct fingerprintingapps/server/AliasVault.Client/wwwroot/index.html++# Exclude local web app build, test and dev output+apps/web/dist+apps/web/playwright-report+apps/web/tests/test-results+apps/web/public/appsettings.Development.jsondiff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.ymlindex 6e2d4ed92..81eaf0eab 100644--- a/.github/workflows/docker-build.yml+++ b/.github/workflows/docker-build.yml@@ -5,6 +5,8 @@ on:branches: [ "main" ]paths:- 'apps/server/**'+ - 'apps/web/**'+ - 'core/**'- 'dockerfiles/**'- 'docker-compose.yml'- 'install.sh'@@ -13,6 +15,8 @@ on:branches: [ "main" ]paths:- 'apps/server/**'+ - 'apps/web/**'+ - 'core/**'- 'dockerfiles/**'- 'docker-compose.yml'- 'install.sh'diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.ymlindex 373eb454f..822bf9a67 100644--- a/.github/workflows/release-docker.yml+++ b/.github/workflows/release-docker.yml@@ -147,9 +147,9 @@ jobs:uses: ./.github/actions/build-docker-imagewith:image: client- dockerfile: apps/server/AliasVault.Client/Dockerfile+ dockerfile: apps/web/Dockerfiletitle: AliasVault Client- description: Blazor WebAssembly client UI for AliasVault. Part of multi-container setup and can be deployed via install.sh (see docs.aliasvault.com)+ description: React web client UI for AliasVault. Part of multi-container setup and can be deployed via install.sh (see docs.aliasvault.com)version: ${{ needs.detect-version.outputs.version }}tag_latest: ${{ needs.detect-version.outputs.tag_latest }}github_token: ${{ secrets.GITHUB_TOKEN }}diff --git a/apps/web/Dockerfile b/apps/web/Dockerfilenew file mode 100644index 000000000..6aa1f40fa--- /dev/null+++ b/apps/web/Dockerfile@@ -0,0 +1,53 @@+# ============================================+# Stage: Build core libraries+# ============================================+# Use BUILDPLATFORM to run on native arch instead of emulating arm64. WASM output is platform-independent.+FROM --platform=$BUILDPLATFORM rust:1-slim-trixie AS core-builder++RUN apt-get update && \+ apt-get install -y --no-install-recommends curl ca-certificates clang llvm && \+ curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \+ apt-get install -y --no-install-recommends nodejs && \+ rustup target add wasm32-unknown-unknown && \+ cargo install wasm-pack --locked && \+ apt-get clean && \+ rm -rf /var/lib/apt/lists/*++WORKDIR /src+COPY core/ ./core/+RUN cd ./core && \+ chmod +x build-and-distribute.sh && \+ ./build-and-distribute.sh --web++# ============================================+# Stage: Build the web app+# ============================================+FROM --platform=$BUILDPLATFORM node:20-bookworm-slim AS build+WORKDIR /src++COPY --from=core-builder /src/core/ ./core/+COPY apps/web/ ./apps/web/++WORKDIR /src/apps/web+RUN npm ci --no-audit --no-fund && npm run build++# ============================================+# Stage: Serve with nginx+# ============================================+FROM nginx:1.24.0 AS final++LABEL org.opencontainers.image.source="https://github.com/aliasvault/aliasvault"+LABEL org.opencontainers.image.vendor="AliasVault"+LABEL org.opencontainers.image.licenses="AGPL-3.0"+LABEL org.opencontainers.image.title="AliasVault Client"+LABEL org.opencontainers.image.description="React web client UI for AliasVault. Part of multi-container setup and can be deployed via install.sh (see docs.aliasvault.com)"++WORKDIR /usr/share/nginx/html+COPY --from=build /src/apps/web/dist .+COPY apps/web/nginx.conf /etc/nginx/nginx.conf+COPY apps/web/entrypoint.sh /app/entrypoint.sh++RUN chmod +x /app/entrypoint.sh++EXPOSE 3000+ENTRYPOINT ["/app/entrypoint.sh"]diff --git a/apps/web/entrypoint.sh b/apps/web/entrypoint.shnew file mode 100755index 000000000..718807570--- /dev/null+++ b/apps/web/entrypoint.sh@@ -0,0 +1,81 @@+#!/bin/sh+# Set the default values+DEFAULT_PRIVATE_EMAIL_DOMAINS=""+DEFAULT_HIDDEN_PRIVATE_EMAIL_DOMAINS=""+DEFAULT_SUPPORT_EMAIL=""+DEFAULT_PUBLIC_REGISTRATION_ENABLED="true"++# Use the provided environment variables if they exist, otherwise use defaults+PRIVATE_EMAIL_DOMAINS=${PRIVATE_EMAIL_DOMAINS:-$DEFAULT_PRIVATE_EMAIL_DOMAINS}+HIDDEN_PRIVATE_EMAIL_DOMAINS=${HIDDEN_PRIVATE_EMAIL_DOMAINS:-$DEFAULT_HIDDEN_PRIVATE_EMAIL_DOMAINS}+SUPPORT_EMAIL=${SUPPORT_EMAIL:-$DEFAULT_SUPPORT_EMAIL}+PUBLIC_REGISTRATION_ENABLED=${PUBLIC_REGISTRATION_ENABLED:-$DEFAULT_PUBLIC_REGISTRATION_ENABLED}++# Create SSL directory if it doesn't exist+mkdir -p /etc/nginx/ssl++# Generate self-signed SSL certificate if not exists+if [ ! -f /etc/nginx/ssl/nginx.crt ] || [ ! -f /etc/nginx/ssl/nginx.key ]; then+ echo "Generating new SSL certificate (10 years validity)..."+ 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"++ # Set proper permissions+ chmod 644 /etc/nginx/ssl/nginx.crt+ chmod 600 /etc/nginx/ssl/nginx.key+fi++# Remove the default API URL as it's only used for local dev/debugging.+# The app will use a relative URL instead (base url + "/api/" which is the default for the Docker setup).+sed -i "s|\"ApiUrl\": \"http://localhost:5100\",||g" /usr/share/nginx/html/appsettings.json++# Handle empty PRIVATE_EMAIL_DOMAINS by defaulting to empty array+if [ -z "$PRIVATE_EMAIL_DOMAINS" ]; then+ json_array="[]"+else+ # Convert comma-separated list to JSON array+ json_array=$(echo $PRIVATE_EMAIL_DOMAINS | awk '{split($0,a,","); printf "["; for(i=1;i<=length(a);i++) {printf "\"%s\"", a[i]; if(i<length(a)) printf ","} printf "]"}')+fi++# Handle empty HIDDEN_PRIVATE_EMAIL_DOMAINS by defaulting to empty array+if [ -z "$HIDDEN_PRIVATE_EMAIL_DOMAINS" ]; then+ hidden_json_array="[]"+else+ # Convert comma-separated list to JSON array+ hidden_json_array=$(echo $HIDDEN_PRIVATE_EMAIL_DOMAINS | awk '{split($0,a,","); printf "["; for(i=1;i<=length(a);i++) {printf "\"%s\"", a[i]; if(i<length(a)) printf ","} printf "]"}')+fi++# Use sed to update the PrivateEmailDomains field in appsettings.json+sed -i.bak "s|\"PrivateEmailDomains\": \[.*\]|\"PrivateEmailDomains\": $json_array|" /usr/share/nginx/html/appsettings.json++# Add HiddenPrivateEmailDomains field if it doesn't exist, or update it if it does+if grep -q "HiddenPrivateEmailDomains" /usr/share/nginx/html/appsettings.json; then+ sed -i "s|\"HiddenPrivateEmailDomains\": \[.*\]|\"HiddenPrivateEmailDomains\": $hidden_json_array|" /usr/share/nginx/html/appsettings.json+else+ # Insert HiddenPrivateEmailDomains after PrivateEmailDomains+ sed -i "s|\"PrivateEmailDomains\": $json_array|\"PrivateEmailDomains\": $json_array,\n \"HiddenPrivateEmailDomains\": $hidden_json_array|" /usr/share/nginx/html/appsettings.json+fi++# Update support email in appsettings.json+if [ ! -z "$SUPPORT_EMAIL" ]; then+ sed -i "s|\"SupportEmail\": \".*\"|\"SupportEmail\": \"$SUPPORT_EMAIL\"|g" /usr/share/nginx/html/appsettings.json+else+ sed -i "s|\"SupportEmail\": \".*\"|\"SupportEmail\": \"\"|g" /usr/share/nginx/html/appsettings.json+fi++# Update public registration enabled in appsettings.json+sed -i "s|\"PublicRegistrationEnabled\": \".*\"|\"PublicRegistrationEnabled\": \"$PUBLIC_REGISTRATION_ENABLED\"|g" /usr/share/nginx/html/appsettings.json++# Update deployment mode (install / build / aio) so the footer can show how this+# instance was deployed. Comes from .env via install.sh; defaults to empty.+DEPLOYMENT_MODE=${DEPLOYMENT_MODE:-}+if grep -q "DeploymentMode" /usr/share/nginx/html/appsettings.json; then+ sed -i "s|\"DeploymentMode\": \".*\"|\"DeploymentMode\": \"$DEPLOYMENT_MODE\"|g" /usr/share/nginx/html/appsettings.json+else+ sed -i "s|\"PublicRegistrationEnabled\": \"$PUBLIC_REGISTRATION_ENABLED\"|\"PublicRegistrationEnabled\": \"$PUBLIC_REGISTRATION_ENABLED\",\n \"DeploymentMode\": \"$DEPLOYMENT_MODE\"|g" /usr/share/nginx/html/appsettings.json+fi++# Start the application+nginx -g "daemon off;"diff --git a/apps/web/nginx.conf b/apps/web/nginx.confnew file mode 100644index 000000000..06cbaa18e--- /dev/null+++ b/apps/web/nginx.conf@@ -0,0 +1,58 @@+events {+ worker_connections 1024;+}++http {+ include /etc/nginx/mime.types;+ default_type application/octet-stream;++ # Add MIME type mapping for JavaScript modules+ types {+ application/javascript mjs;+ }++ # Gzip Settings+ gzip on;+ gzip_vary on;+ gzip_proxied any;+ gzip_comp_level 6;+ gzip_buffers 16 8k;+ gzip_http_version 1.1;+ gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;++ server {+ listen 3000;+ server_name localhost;++ # Never cache index.html, appsettings.json and service-worker.js. index.html references the+ # content hashed bundle and must always be fresh so users get the latest release.+ location ~* ^/(index\.html|appsettings\.json|service-worker\.js)$ {+ root /usr/share/nginx/html;+ add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";+ add_header Pragma "no-cache";+ try_files $uri =404;+ }++ # Everything Vite emits under /assets (JS, CSS, the Rust core wasm) carries a content hash in its+ # name, so it can be cached forever: a new release references new file names.+ location ^~ /assets/ {+ root /usr/share/nginx/html;+ add_header Cache-Control "public, max-age=31536000, immutable";+ try_files $uri =404;+ }++ # Files copied from public/ (favicon, images) keep their names across releases, so the browser+ # revalidates them with the ETag.+ location ~* \.(css|js|mjs|json|woff|woff2|ttf|eot|png|jpg|jpeg|gif|ico|svg|webp|wasm)$ {+ root /usr/share/nginx/html;+ add_header Cache-Control "no-cache";+ try_files $uri =404;+ }++ # All app routes fall back to index.html.+ location / {+ root /usr/share/nginx/html;+ try_files $uri $uri/ /index.html;+ }+ }+}diff --git a/docker-compose.yml b/docker-compose.ymlindex 7fd53ec7f..6e96c7e0f 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -20,8 +20,6 @@ services:client:image: ghcr.io/aliasvault/client:latest- volumes:- - ./logs/msbuild:/apps/server/msbuild-logs:rwexpose:- "3000"restart: alwaysdiff --git a/dockerfiles/all-in-one/Dockerfile b/dockerfiles/all-in-one/Dockerfileindex 8eae41e88..bd750b0bc 100644--- a/dockerfiles/all-in-one/Dockerfile+++ b/dockerfiles/all-in-one/Dockerfile@@ -22,47 +22,39 @@ WORKDIR /src# Copy core library source filesCOPY core/ ./core/-# Build core libraries (only browser target needed for server apps)+# Build core librariesRUN cd ./core && \chmod +x build-and-distribute.sh && \./build-and-distribute.sh --web# ============================================-# Stage 2: Build .NET applications+# Stage 2: Build the web app# ============================================-FROM mcr.microsoft.com/dotnet/sdk:10.0-noble AS dotnet-builder+FROM --platform=$BUILDPLATFORM node:20-bookworm-slim AS web-builder+WORKDIR /src-# Install Python (required for WASM compilation) and Node.js (required by JS bundler)-RUN apt-get update && \- apt-get install -y --no-install-recommends python3 python3-pip curl ca-certificates && \- curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \- apt-get install -y --no-install-recommends nodejs && \- apt-get clean && \- rm -rf /var/lib/apt/lists/*+COPY --from=core-builder /src/core/ ./core/+COPY apps/web/ ./apps/web/++WORKDIR /src/apps/web+RUN npm ci --no-audit --no-fund && npm run build++# ============================================+# Stage 3: Build .NET applications+# ============================================+FROM mcr.microsoft.com/dotnet/sdk:10.0-noble AS dotnet-builderWORKDIR /src# Copy all source filesCOPY apps/server/ ./apps/server/-# Copy built core libraries from core-builder stage-COPY --from=core-builder /src/core/ ./core/--# Copy Rust WASM output to Client wwwroot/wasm/-RUN mkdir -p ./apps/server/AliasVault.Client/wwwroot/wasm && \- cp ./core/rust/dist/wasm/aliasvault_core_bg.wasm ./apps/server/AliasVault.Client/wwwroot/wasm/ && \- cp ./core/rust/dist/wasm/aliasvault_core.js ./apps/server/AliasVault.Client/wwwroot/wasm/--# Copy TypeScript core packages to Client wwwroot/js/dist/core/-RUN mkdir -p ./apps/server/AliasVault.Client/wwwroot/js/dist/core/vault && \- cp -r ./core/vault/dist/* ./apps/server/AliasVault.Client/wwwroot/js/dist/core/vault/--# Install required .NET workloads and restore packages once for the entire solutionWORKDIR /src/apps/server-# Install workloads and restore packages once for the entire solution-RUN dotnet workload install wasm-tools && \- dotnet restore aliasvault.sln+# Restore only the published projects explicitly (not the legacy Blazor WASM client)+RUN for project in AliasVault.Api/AliasVault.Api.csproj AliasVault.Admin/AliasVault.Admin.csproj Services/AliasVault.SmtpService/AliasVault.SmtpService.csproj Services/AliasVault.TaskRunner/AliasVault.TaskRunner.csproj Utilities/AliasVault.InstallCli/AliasVault.InstallCli.csproj; do \+ dotnet restore "$project" || exit 1; \+ done# Build each application in separate layers to avoid lock contention@@ -70,13 +62,6 @@ RUN dotnet workload install wasm-tools && \RUN dotnet publish AliasVault.Api/AliasVault.Api.csproj \-c Release -o /app/api --no-restore-# Build Client (contains WASM which can be slow)-# Note: Must run build first before publish, to trigger index.html generation for correct fingerprinting-RUN dotnet build AliasVault.Client/AliasVault.Client.csproj \- -c Release --no-restore && \- dotnet publish AliasVault.Client/AliasVault.Client.csproj \- -c Release -o /app/client --no-restore-# Build AdminRUN dotnet publish AliasVault.Admin/AliasVault.Admin.csproj \-c Release -o /app/admin --no-restore@@ -100,7 +85,7 @@ RUN find /app -name "*.pdb" -delete && \find /app -name "web.config" -delete# ============================================-# Stage 3: Download s6-overlay separately+# Stage 4: Download s6-overlay separately# ============================================FROM alpine:3.19 AS s6-downloaderARG S6_OVERLAY_VERSION=3.2.0.2@@ -113,7 +98,7 @@ RUN ARCH="${TARGETARCH}"; \mv s6-overlay-${ARCH}.tar.xz s6-overlay-arch.tar.xz# ============================================-# Stage 4: Final runtime image+# Stage 5: Final runtime image# ============================================FROM mcr.microsoft.com/dotnet/aspnet:10.0-noble@@ -179,12 +164,13 @@ RUN apt-get update && \/var/run/postgresql \/etc/s6-overlay/s6-rc.d/user/contents.d-# Copy built applications and all configuration files from builder stage+# Copy built applications and all configuration files from builder stagesCOPY --from=dotnet-builder /app /app+COPY --from=web-builder /src/apps/web/dist /app/client/wwwroot# Copy all scripts from scripts directory to /usr/local/binCOPY dockerfiles/all-in-one/scripts/ /usr/local/bin/-COPY apps/server/AliasVault.Client/nginx.conf /app/client/nginx.conf+COPY apps/web/nginx.conf /app/client/nginx.confCOPY dockerfiles/all-in-one/config/nginx-80-443.conf /etc/nginx/nginx-80-443.confCOPY dockerfiles/all-in-one/config/nginx-443.conf /etc/nginx/nginx-443.confCOPY apps/server/status.html /usr/share/nginx/html/status.htmldiff --git a/dockerfiles/docker-compose.build.yml b/dockerfiles/docker-compose.build.ymlindex 7243a4039..8699308a4 100644--- a/dockerfiles/docker-compose.build.yml+++ b/dockerfiles/docker-compose.build.yml@@ -9,7 +9,7 @@ services:image: aliasvault-clientbuild:context: .- dockerfile: apps/server/AliasVault.Client/Dockerfile+ dockerfile: apps/web/Dockerfileapi:image: aliasvault-apidiff --git a/scripts/local-docker-build-push.sh b/scripts/local-docker-build-push.shindex 48d27b2ba..bcc5fbb85 100755--- a/scripts/local-docker-build-push.sh+++ b/scripts/local-docker-build-push.sh@@ -106,7 +106,7 @@ build_multi() {local images=("postgres:apps/server/Databases/AliasServerDb/Dockerfile""api:apps/server/AliasVault.Api/Dockerfile"- "client:apps/server/AliasVault.Client/Dockerfile"+ "client:apps/web/Dockerfile""admin:apps/server/AliasVault.Admin/Dockerfile""reverse-proxy:apps/server/Dockerfile""smtp:apps/server/Services/AliasVault.SmtpService/Dockerfile"