Skip to content

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

Add docs deploy (#2189)

Leendert de Borste52a67b70a38
diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml
new file mode 100644
index 000000000..c8ae80225
--- /dev/null
+++ b/.github/workflows/deploy-docs.yml
@@ -0,0 +1,76 @@
+# Deploys the documentation site (docs/) to docs.aliasvault.com.
+#
+# Triggers:
+# - Automatically on every published GitHub release.
+# - Manually via "Run workflow" (workflow_dispatch).
+name: Deploy docs
+
+on:
+ release:
+ types: [published]
+ workflow_dispatch:
+ inputs:
+ ref:
+ description: 'Branch or tag to deploy the docs from (defaults to the branch this workflow is run on)'
+ required: false
+ type: string
+
+# Never run two deploys at once; cancel-in-progress is off so an in-flight
+# deploy finishes cleanly before the next one starts.
+concurrency:
+ group: deploy-docs
+ cancel-in-progress: false
+
+jobs:
+ deploy:
+ name: Deploy docs to production
+ runs-on: ubuntu-latest
+ environment:
+ name: docs-production
+ url: https://docs.aliasvault.com
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.ref || github.ref }}
+ sparse-checkout: docs
+
+ # Build the static site in CI, we only deploy the built site to the server.
+ - name: Setup Node
+ uses: actions/setup-node@v4
+ with:
+ node-version: 20
+ cache: npm
+ cache-dependency-path: docs/package-lock.json
+
+ - name: Build static site
+ working-directory: docs
+ run: |
+ npm ci
+ npm run build
+
+ - name: Setup SSH
+ run: |
+ mkdir -p ~/.ssh
+ echo "${{ secrets.DOCS_DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
+ chmod 600 ~/.ssh/deploy_key
+ ssh-keyscan -H "${{ secrets.DOCS_DEPLOY_HOST }}" >> ~/.ssh/known_hosts
+
+ # Rsync the pre-built static site plus the small serving config.
+ - name: Rsync docs to server
+ run: |
+ rsync -az --delete \
+ -e "ssh -i ~/.ssh/deploy_key" \
+ ./docs/build \
+ ./docs/nginx.conf \
+ ./docs/Dockerfile \
+ ./docs/.dockerignore \
+ ./docs/docker-compose.yml \
+ ${{ secrets.DOCS_DEPLOY_USER }}@${{ secrets.DOCS_DEPLOY_HOST }}:/opt/docs/
+
+ - name: Rebuild and restart Docker Compose
+ run: |
+ ssh -i ~/.ssh/deploy_key \
+ ${{ secrets.DOCS_DEPLOY_USER }}@${{ secrets.DOCS_DEPLOY_HOST }} \
+ "cd /opt/docs && docker compose up -d --build --force-recreate && docker system prune -af"
diff --git a/docs/.dockerignore b/docs/.dockerignore
index 1bda17013..d60f8e667 100644
--- a/docs/.dockerignore
+++ b/docs/.dockerignore
@@ -1,5 +1,5 @@
+# The static `build/` output is intentionally NOT ignored as the Docker image serves it.
node_modules
-build
.docusaurus
.git
Dockerfile
diff --git a/docs/Dockerfile b/docs/Dockerfile
index 04d830125..319c5f82f 100644
--- a/docs/Dockerfile
+++ b/docs/Dockerfile
@@ -1,13 +1,8 @@
-# Build the Docusaurus static site, then serve it with nginx.
-FROM node:20-alpine AS build
-WORKDIR /app
-COPY package.json package-lock.json ./
-RUN npm ci
-COPY . .
-RUN npm run build
-
+# Serve a pre-built Docusaurus static site with nginx.
+#
+# To build locally first: `npm ci && npm run build`, then `docker compose up --build`.
FROM nginx:alpine
-COPY --from=build /app/build /usr/share/nginx/html
+COPY build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
diff --git a/docs/README.md b/docs/README.md
new file mode 100644
index 000000000..c8b633189
--- /dev/null
+++ b/docs/README.md
@@ -0,0 +1,35 @@
+# AliasVault documentation
+
+The documentation site for AliasVault ([docs.aliasvault.net](https://docs.aliasvault.net)),
+built with [Docusaurus](https://docusaurus.io/).
+
+## Run locally (development)
+
+Hot-reloading dev server:
+
+```bash
+npm ci # first time, or when dependencies change
+npm start # serves at http://localhost:5190
+```
+
+## Run locally with Docker
+
+Serves the production build through nginx, exactly as it runs in production.
+The site must be built first, then Docker just serves the static output:
+
+```bash
+npm ci && npm run build # produces ./build
+docker compose up -d --build # serves at http://localhost:5191
+docker compose down # stop
+```
+
+## Deployment
+
+Deployment is automated — see [`.github/workflows/deploy-docs.yml`](../.github/workflows/deploy-docs.yml).
+It builds the static site in CI and ships it to the docs server:
+
+- **Automatically** on every published GitHub release.
+- **Manually** via the Actions tab → *Deploy docs* → *Run workflow*, where you
+ can choose the branch or tag to deploy from.
+
+Server-side setup is documented internally.
diff --git a/docs/docker-compose.yml b/docs/docker-compose.yml
index 73cd8331b..06995113f 100644
--- a/docs/docker-compose.yml
+++ b/docs/docker-compose.yml
@@ -1,8 +1,10 @@
# Docker Compose file for the AliasVault documentation (Docusaurus).
#
-# Builds the static site and serves it with nginx in production mode.
+# Serves the pre-built static site (`build/`) with nginx. The site has
+# to be built manually with `npm ci && npm run build` first (in CI or manually locally).
#
-# Usage:
+# Usage (after `npm ci && npm run build`):
+# npm ci && npm run build
# docker compose up -d --build
# docker compose down
#
@@ -11,5 +13,5 @@ services:
build:
context: .
ports:
- - "4000:80"
+ - "127.0.0.1:5191:80"
restart: unless-stopped
diff --git a/docs/package.json b/docs/package.json
index 93f213d08..60a05925e 100644
--- a/docs/package.json
+++ b/docs/package.json
@@ -5,9 +5,9 @@
"description": "AliasVault documentation",
"scripts": {
"docusaurus": "docusaurus",
- "start": "docusaurus start",
+ "start": "docusaurus start --port 5190",
"build": "docusaurus build",
- "serve": "docusaurus serve",
+ "serve": "docusaurus serve --port 5190",
"clear": "docusaurus clear",
"swizzle": "docusaurus swizzle",
"typecheck": "tsc"