Skip to main content

Docmost on GKE Autopilot

Docmost on GKE Autopilot

Docmost is an open-source, real-time collaborative wiki and documentation platform (a Confluence/Notion alternative) built on NestJS. This module deploys Docmost on GKE Autopilot on top of the App_GKE foundation, which provisions and manages the shared Google Cloud and Kubernetes infrastructure.

This guide focuses on the cloud services Docmost uses and how to explore and operate them from the Google Cloud Console and the command line. For the mechanics that are common to every GKE application — Workload Identity, ingress, autoscaling, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC Service Controls, backups, and the deployment lifecycle — refer to the App_GKE foundation guide rather than repeating them here.


1. Overview

Docmost runs as a Node.js (NestJS) web workload on port 3000. The deployment wires together a focused set of Google Cloud services:

CapabilityGoogle Cloud serviceNotes
ComputeGKE AutopilotNestJS pods on port 3000, horizontally autoscaled between 1 and 3 replicas
DatabaseCloud SQL for PostgreSQL 15Required — Docmost does not support MySQL or other engines
Cache & collaborationRedisRequired for real-time editing and background queues; enabled by default
File storageFilestore / NFSAttachments written to the NFS-backed volume at /app/data/storage
Object storageCloud StorageA data bucket provisioned automatically (unused by the default local driver)
SecretsSecret ManagerAuto-generated APP_SECRET; database password
IngressCloud Load BalancingExternal LoadBalancer, optional custom domain + managed certificate

Sensible defaults worth knowing up front:

  • PostgreSQL 15 is mandatory. The database engine is fixed by the shared application layer; selecting any other engine breaks startup.
  • Redis is required and on by default. Docmost uses Redis for real-time collaborative editing and background job queues. enable_redis = true is the default; leaving redis_host empty co-locates Redis on the NFS server VM.
  • NFS is enabled by default (enable_nfs = true, nfs_mount_path = /app/data/storage). Docmost's local storage driver writes uploaded attachments there so they survive pod restarts and are shared across replicas.
  • APP_SECRET is generated automatically and stored in Secret Manager (also materialised into a Kubernetes Secret via the explicit-secret-values path). It signs and encrypts sessions and sensitive data and must never be rotated after first boot without a maintenance window.
  • The database is reached via the Cloud SQL Auth Proxy sidecar on 127.0.0.1 (plaintext loopback, sslmode=disable) — the entrypoint branches on DB_HOST to pick the right connection form and SSL mode per platform.
  • A custom image is built via Cloud Build (container_image_source = "custom", base docmost/docmost:latest) wrapping the official image with the entrypoint that assembles DATABASE_URL / REDIS_URL / APP_URL. Rebuilt images deploy with imagePullPolicy=Always.
  • Minimum 1 replica is maintained (min_instance_count = 1; GKE does not support scale-to-zero) to keep the wiki and collaboration endpoint always reachable.
  • First-run setup is via the UI. Docmost has no default credentials — the first visitor creates the initial workspace and administrator account.

2. Google Cloud Services & How to Explore Them

All commands assume you have run gcloud container clusters get-credentials <cluster> --region <region> --project <project> and that PROJECT, REGION, and NAMESPACE are set. The namespace and other identifiers are reported in the deployment Outputs.

A. GKE Autopilot — the Docmost workload

Docmost pods are scheduled on Autopilot, which bills for the CPU/memory the pods actually request. Horizontal Pod Autoscaling sizes the deployment between the minimum and maximum replica counts. Because attachments live on the shared NFS volume, the Deployment uses the Recreate strategy for updates to avoid two pods writing the same NFS/DB state during a rollout.

  • Console: Kubernetes Engine → Workloads → select the Docmost workload to see pods, revisions, and events. Kubernetes Engine → Services & Ingress shows the external IP.
  • CLI:
    kubectl get pods,svc,hpa -n "$NAMESPACE"
    kubectl logs -n "$NAMESPACE" deploy/<service-name> --tail=100
    kubectl describe hpa -n "$NAMESPACE" # current vs target utilisation

See App_GKE for how Autopilot, scaling, and the workload type (Deployment vs StatefulSet) are managed.

B. Cloud SQL for PostgreSQL 15

Docmost stores all application data (spaces, pages, comments, users, permissions) in a managed Cloud SQL for PostgreSQL 15 instance. Pods reach it privately through the Cloud SQL Auth Proxy sidecar over 127.0.0.1 (plaintext loopback); no public IP is exposed. On first deploy an initialization Job creates the application database and user; Docmost then applies its own schema migrations automatically on boot.

  • Console: SQL → select the instance for connections, backups, flags, and metrics.
  • CLI:
    gcloud sql instances list --project "$PROJECT"
    gcloud sql instances describe <instance-name> --project "$PROJECT"
    # Open an interactive shell to inspect schema/data:
    gcloud sql connect <instance-name> --user=<db-user> --database=<db-name> --project "$PROJECT"

The instance name, database (docmost), user (docmost), and the Secret Manager secret holding the password are all surfaced in the Outputs. For the connection model, automated backups, and password rotation, see App_GKE.

C. Redis (real-time collaboration & queues)

Redis is enabled by default and is required for Docmost's real-time collaborative editor and background job processing. When redis_host is left empty and enable_nfs is true, the NFS server VM's IP is used as the Redis endpoint; set redis_host (and optionally redis_auth) to point at a managed/external Redis instead.

  • Console: Memorystore → Redis (if using a managed instance).
  • CLI:
    redis-cli -h <redis-host> ping
    redis-cli -h <redis-host> info keyspace
    # Confirm REDIS_URL is assembled inside the running pod:
    kubectl exec -n "$NAMESPACE" deploy/<service-name> -- env | grep REDIS_URL

D. Cloud Storage & NFS file storage

Docmost writes uploaded attachments to its local storage driver at /app/data/storage, backed by the NFS volume so files persist across pod restarts and are shared across replicas. A dedicated Cloud Storage data bucket is also provisioned automatically (available if you switch Docmost to an object-storage driver).

  • Console: Cloud Storage → Buckets; Filestore → Instances.
  • CLI:
    gcloud storage buckets list --project "$PROJECT"
    gcloud filestore instances list --project "$PROJECT"
    kubectl get pvc -n "$NAMESPACE"

See App_GKE for CMEK options and GCS Fuse mounts.

E. Secret Manager

One cryptographic secret is generated automatically and stored in Secret Manager: APP_SECRET (used to sign and encrypt sessions and sensitive data). On GKE it is also materialised into a Kubernetes Secret. The database password is managed separately by the foundation.

  • Console: Security → Secret Manager.
  • CLI:
    gcloud secrets list --project "$PROJECT" --filter="name~docmost"
    gcloud secrets versions access latest --secret=<secret-name> --project "$PROJECT"
    kubectl get secret -n "$NAMESPACE"

See App_GKE for the Secret Store CSI integration and rotation.

F. Networking & ingress

By default the workload is exposed through an external Cloud Load Balancing IP (service_type = LoadBalancer). A custom domain with a Google-managed certificate can be enabled, and a static IP can be reserved so the address survives redeploys.

  • Console: Network services → Load balancing; VPC network → IP addresses.
  • CLI:
    kubectl get ingress,svc -n "$NAMESPACE"
    gcloud compute addresses list --project "$PROJECT"

See App_GKE for custom domains, Cloud CDN, and static IP details.

G. Cloud Logging & Monitoring

Pod stdout/stderr flow to Cloud Logging; GKE and Cloud SQL metrics flow to Cloud Monitoring. Optional uptime checks and alert policies are available.

  • Console: Logging → Logs Explorer; Monitoring → Dashboards / Alerting.
  • CLI:
    gcloud logging read 'resource.type="k8s_container" AND resource.labels.namespace_name="'"$NAMESPACE"'"' \
    --project "$PROJECT" --limit 50

3. Docmost Application Behaviour

  • First-deploy database setup. An initialization Job runs db-init.sh using postgres:15-alpine. It connects through the Cloud SQL Auth Proxy and idempotently creates the application database and user and grants privileges, then signals the proxy sidecar to shut down so the Job can complete. The job is safe to re-run.
  • Migrations run automatically on start. Docmost runs its own schema migrations on every boot via its default pnpm start command, so upgrading the application version applies schema changes with no separate migration step.
  • APP_SECRET is immutable after first boot. It is generated once and written to Secret Manager (and a Kubernetes Secret). Rotating it invalidates all existing sessions and makes data encrypted under the old value unrecoverable — only rotate in a planned maintenance window.
  • APP_URL must match the reachable URL. It is injected as the internal/predicted service URL and used for absolute links and the collaboration WebSocket. After the external LoadBalancer IP (or custom domain) is known, set APP_URL to that external URL via environment_variables (or patch the Deployment):
    kubectl set env deploy/<service-name> -n "$NAMESPACE" APP_URL="https://docmost.example.com"
  • Health path. Startup and liveness probes target /api/health — Docmost's public 200 endpoint. Allow ~2 minutes on first boot while migrations run.
  • First-run account creation. Docmost ships with no default credentials. Browse to the LoadBalancer IP / domain and complete the setup form to create the first workspace and admin user. Do this promptly after deploy.
  • Custom-build rebuilds. Because the image is custom-built, rebuilt images reuse a version tag; App_GKE sets imagePullPolicy=Always so nodes pull the fresh image rather than serving a stale cached layer.

4. Configuration Variables

Variables are grouped exactly as they appear on the deployment platform. Only settings specific to or notable for Docmost are listed; every other input is inherited from App_GKE with its standard behaviour and defaults.

Group 1 — Project & Identity

VariableDefaultDescription
project_id(required)Target Google Cloud project.
regionus-central1Region for the workload and regional resources.

Group 2 — Deployment Environment

VariableDefaultDescription
tenant_deployment_iddemoShort suffix that makes resource names unique per environment.
support_users[]Emails granted project access and monitoring alerts.
resource_labels{}Labels applied to all resources for cost/ownership tracking.

Group 3 — Application Identity

VariableDefaultDescription
application_namedocmostBase name for resources. Do not change after first deploy.
application_display_nameDocmostHuman-readable name shown in the Console.
application_versionlatestDocmost image tag (mapped to the DOCMOST_VERSION build ARG); pin to a specific release in production.

Group 4 — Container & Scale

VariableDefaultDescription
deploy_applicationtrueSet false to provision infrastructure only.
container_image_sourcecustomDocmost is built from a custom Dockerfile wrapping the official image.
container_imagedocmost/docmost:latestUpstream base image the custom build wraps.
container_port3000Docmost listens on port 3000.
min_instance_count1Minimum replicas; GKE requires ≥ 1 (no scale-to-zero).
max_instance_count3Maximum replicas.
enable_cloudsql_volumetrueCloud SQL Auth Proxy sidecar for the loopback connection.
enable_image_mirroringtrueMirror the built image into Artifact Registry before deployment.

Group 5 — Environment Variables & Secrets

VariableDefaultDescription
environment_variables{}Extra non-secret settings. Core values (NODE_ENV, STORAGE_DRIVER, APP_URL) are set automatically — do not set APP_SECRET, DATABASE_URL, or REDIS_URL here.
secret_environment_variables{}Map of env var → Secret Manager secret name.
secret_propagation_delay30Seconds to wait after secret creation before proceeding.
secret_rotation_period2592000sSecret Manager rotation notification frequency.

Group 6 — GKE Backend & Cluster

VariableDefaultDescription
service_typeLoadBalancerHow the Kubernetes Service is exposed.
workload_typenullResolves to Deployment (stateless; state is in Postgres/NFS).
session_affinityClientIPSticky routing keeps a client's collaboration WebSocket on one pod.
namespace_name""Namespace (defaults to the derived per-app namespace).
termination_grace_period_seconds30Seconds to wait after SIGTERM before SIGKILL.
enable_network_segmentationfalseCreate Kubernetes NetworkPolicy resources.

Group 7 — StatefulSet

VariableDefaultDescription
stateful_pvc_enablednullLeave off — Docmost keeps state in PostgreSQL and shared NFS, not per-pod PVCs.
stateful_pvc_size10GiPer-pod PVC size (only if a StatefulSet is chosen).

Group 8 — Resource Quota

VariableDefaultDescription
enable_resource_quota / quota_memory_requests / quota_memory_limitsfalse / "" / ""Not referenced — the whole Group 8 block is declared for interface compatibility only; it has no effect on this module's deployment.

Group 9 — Reliability Policies

VariableDefaultDescription
enable_pod_disruption_budgettrueProtect availability during node upgrades.
pdb_min_available1Minimum pods available during voluntary disruptions.

Group 10 — Observability & Health

VariableDefaultDescription
startup_probe_configHTTP /api/health 60s delayStartup probe. Allow ~2 minutes on first boot.
health_check_configHTTP /api/healthLiveness probe.
uptime_check_config(set)Optional Cloud Monitoring uptime check (public endpoint).
alert_policies[]Optional metric alert policies.

Group 13 — Filesystem (NFS)

VariableDefaultDescription
enable_nfstrueNFS is on by default — backs the /app/data/storage attachment path.
nfs_mount_path/app/data/storageMount path matching Docmost's local storage driver.

Group 14 — Cloud Storage & Artifact Registry

VariableDefaultDescription
create_cloud_storagetrueCreate the GCS buckets defined in storage_buckets.
storage_buckets[]Additional buckets beyond the auto-provisioned data bucket.
gcs_volumes[]GCS Fuse volume mounts via the CSI driver.
max_images_to_retain / delete_untagged_images / image_retention_days(set)Artifact Registry cleanup policy.

Group 15 — Redis Cache & Queue

VariableDefaultDescription
enable_redistrueRequired — Docmost uses Redis for real-time editing and queues.
redis_host""Redis endpoint. Leave empty to use the NFS server IP.
redis_port6379Redis port.
redis_auth""Optional Redis auth password (sensitive).

Group 16 — Database Backend

VariableDefaultDescription
database_typePOSTGRES_15Fixed — Docmost requires PostgreSQL 15.
application_database_namedocmostPostgreSQL database name. Immutable after first deploy.
application_database_userdocmostApplication database user. Immutable after first deploy.
database_password_length32Generated password length.

All other inputs follow standard App_GKE behaviour.


5. Outputs

These values are returned on a successful deployment and are the quickest way to locate and explore the running resources.

OutputDescription
service_nameKubernetes Service name.
namespaceNamespace the workload runs in.
service_cluster_ipIn-cluster ClusterIP.
stage_service_cluster_ipsMap of ClusterIPs for stage-specific services.
service_external_ipExternal LoadBalancer IP (when a static IP is reserved).
service_urlURL to reach Docmost.
database_instance_nameCloud SQL instance name.
database_nameApplication database name.
database_userApplication database user.
database_password_secretSecret Manager secret holding the DB password.
database_host / database_portDB endpoint (127.0.0.1 via the Auth Proxy) / port.
storage_bucketsCreated Cloud Storage buckets.
network_name / network_exists / regionsVPC network, presence, available regions.
container_image / container_registryDeployed image and Artifact Registry repo.
monitoring_enabled / monitoring_notification_channelsMonitoring status and channels.
initialization_jobs / db_import_jobNames of the setup and (optional) import jobs.
deployment_id / tenant_id / resource_prefixNaming identifiers.
project_id / project_numberProject identifiers.
cicd_enabled / cicd_configurationCI/CD status and details (repo, trigger, registry).
github_repository_url / github_repository_owner / github_repository_nameCI/CD GitHub details.
artifact_registry_repository / cloudbuild_trigger_name / cloudbuild_trigger_idRegistry and build trigger.
kubernetes_readyWhether the cluster/workload is ready.
vpc_sc_enabled / vpc_sc_perimeter_name / vpc_sc_dry_run_modeVPC-SC status.
audit_logging_enabled / artifact_registry_cmek_enabledAudit logging and CMEK status.

6. Configuration Pitfalls & Sensible Defaults

Risk: Critical (data loss / outage / security) — High (service degraded) — Medium (cost or partial degradation) — Low (minor).

Inherited plan-time validation. This module passes its configuration through the App_GKE foundation engine, which validates values and combinations at plan time — a read replica without its primary, IAP with no authorized identities, a gen1 runtime with NFS/GCS mounts, a database_type that does not match an enabled extension, an out-of-range redis_port/backup_retention_days, a bare-integer memory quota. Invalid configuration fails the plan with a clear, named error before any resource is created, so most mistakes below are caught up front rather than at apply or runtime.

SettingSensible valueRiskConsequence if wrong
APP_SECRET (auto-generated)Never rotate after first bootCriticalRotating it invalidates all sessions and makes data encrypted under the old value unrecoverable.
application_database_name / application_database_userSet onceCriticalImmutable after first deploy; renaming recreates the DB/user and destroys all data.
database_typePOSTGRES_15CriticalDocmost requires PostgreSQL 15; any other engine breaks startup.
enable_redistrueCriticalDocmost's real-time editor and job queues need Redis; disabling it prevents the app from working correctly.
enable_nfstrueHighWith NFS off, uploaded attachments land on ephemeral pod disk and are lost on restart / not shared across replicas.
APP_URLExternal LoadBalancer / domain URLHighA wrong URL breaks absolute links and the collaboration WebSocket endpoint.
session_affinityClientIPHighWithout stickiness, a client's collaboration WebSocket can reconnect to a different pod.
enable_cloudsql_volumetrueHighThe Auth Proxy sidecar is required for the loopback PostgreSQL connection.
min_instance_count1HighGKE requires min ≥ 1; keeping 1 ensures the wiki is always reachable.
stateful_pvc_enabledleave offMediumPer-pod PVCs are unnecessary — Docmost keeps state in Postgres/NFS; enabling adds cost/complexity.
enable_pod_disruption_budgettrueMediumDisabling allows GKE to evict all pods simultaneously during maintenance.

For the foundation behaviour referenced throughout — IAM and Workload Identity, autoscaling, ingress and certificates, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC-SC, backups, and image mirroring — see App_GKE. Docmost-specific application configuration shared with the Cloud Run variant is described in Docmost_Common.