Skip to main content

Dolibarr on Google Cloud Run

Dolibarr on Google Cloud Run

Dolibarr is a free, open-source ERP and CRM suite covering customers and prospects, quotes, orders, invoices, products and stock, HR, projects, and accounting through a modular PHP web UI. This module deploys Dolibarr on Cloud Run v2 on top of the App_CloudRun foundation, which provisions and manages the shared Google Cloud infrastructure.

This guide focuses on the cloud services Dolibarr uses and how to explore and operate them from the Google Cloud Console and the command line. For the mechanics common to every Cloud Run application — service identity, ingress and load balancing, scaling and concurrency, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC Service Controls, backups, and the deployment lifecycle — refer to the App_CloudRun foundation guide rather than repeating them here.


1. Overview

Dolibarr runs as a single PHP/Apache container on Cloud Run v2. The deployment wires together a focused set of Google Cloud services:

CapabilityGoogle Cloud serviceNotes
ComputeCloud Run v2PHP/Apache service on port 80, 1 vCPU / 2 GiB by default, serverless autoscaling; scale-to-zero supported
DatabaseCloud SQL for MySQL 8.0Required — the engine is fixed at MYSQL_8_0
File persistenceCloud Filestore (NFS)Uploaded documents/PDFs persist under /var/lib/dolibarr across restarts
Object storageCloud StorageA dolibarr-documents bucket provisioned automatically
SecretsSecret ManagerAuto-generated DOLI_ADMIN_PASSWORD and DOLI_INSTANCE_UNIQUE_ID; database password
IngressCloud Run URL / Cloud Load BalancingDefault run.app URL; optional external HTTPS load balancer + custom domain

Sensible defaults worth knowing up front:

  • MySQL 8.0 is mandatory. The database engine is fixed by the shared application layer (database_type = MYSQL_8_0); other engines are not supported.
  • Cloud SQL is reached over TCP on the private IP. On Cloud Run this variant defaults enable_cloudsql_volume = false, so Dolibarr and the db-init job connect to the instance's private IP on port 3306 (Cloud SQL MySQL 8 uses caching_sha2_password, handled by the init job).
  • Single instance by default. max_instance_count = 1. Dolibarr keeps session and lock state that is not multi-instance-safe without shared storage and sticky routing — do not raise max_instance_count above 1 without verifying that first.
  • Scale-to-zero is enabled (min_instance_count = 0). Cold starts add a few seconds plus the PHP/Apache boot on the first request after idle; set min_instance_count = 1 for an always-warm service.
  • NFS is enabled by default (enable_nfs = true, mounted at /var/lib/dolibarr) so uploaded documents and generated PDFs survive container recreation.
  • First-boot auto-install. DOLI_INSTALL_AUTO = 1 makes the Dolibarr installer create the schema on first start; there is no separate migration job.
  • DOLI_ADMIN_PASSWORD and DOLI_INSTANCE_UNIQUE_ID are generated automatically and stored in Secret Manager. The admin password is used to create the first-run super-admin account (username DOLI_ADMIN_LOGIN, default admin).
  • DOLI_URL_ROOT is set from the predicted service URL at plan time so absolute links and login redirects resolve to the real Cloud Run address.

2. Google Cloud Services & How to Explore Them

All commands assume PROJECT and REGION are set. Service and resource names are reported in the deployment Outputs.

A. Cloud Run — the Dolibarr service

Dolibarr runs as a Cloud Run v2 service that autoscales by request load between the minimum and maximum instance counts. Each deployment creates an immutable revision; traffic can be split across revisions for safe rollouts.

  • Console: Cloud Run → select the service for revisions, traffic, logs, and metrics.
  • CLI:
    gcloud run services list --project "$PROJECT" --region "$REGION" \
    --filter="metadata.name~dolibarr"
    gcloud run services describe <service-name> --project "$PROJECT" --region "$REGION"
    gcloud run revisions list --service <service-name> --project "$PROJECT" --region "$REGION"

See App_CloudRun for scaling, concurrency, execution environment, and traffic splitting.

B. Cloud SQL for MySQL 8.0

Dolibarr stores all application data (third parties, invoices, products, users, accounting) in a managed Cloud SQL for MySQL 8.0 instance. With the Cloud Run default enable_cloudsql_volume = false, the service connects over TCP to the instance private IP on port 3306; no public IP is exposed. On first deploy the db-init job creates the application database, user, and grants; the Dolibarr installer then creates the schema.

  • Console: SQL → select the instance for connections, backups, flags, metrics.
  • CLI:
    gcloud sql instances list --project "$PROJECT"
    gcloud sql instances describe <instance-name> --project "$PROJECT"
    gcloud sql connect <instance-name> --user=<db-user> --database=<db-name> --project "$PROJECT"

The instance name, database, user, and password secret are in the Outputs. See App_CloudRun for the connection model, backups, and password rotation.

C. Cloud Storage & file persistence

A dedicated Cloud Storage bucket (suffix dolibarr-documents, injected by the Common layer) is provisioned automatically, alongside the standard data-suffix bucket from storage_buckets. Separately, Dolibarr's document tree lives on NFS at /var/lib/dolibarr so uploads and generated PDFs survive container recreation.

  • Console: Cloud Storage → Buckets; Filestore → Instances.
  • CLI:
    gcloud storage buckets list --project "$PROJECT" --filter="name~dolibarr-documents"
    gcloud filestore instances list --project "$PROJECT"

See App_CloudRun for GCS Fuse, NFS, and CMEK options.

D. Secret Manager

Two Dolibarr secrets are generated automatically and stored in Secret Manager: DOLI_ADMIN_PASSWORD (the first-run super-admin password) and DOLI_INSTANCE_UNIQUE_ID (a per-instance security salt). The database password is managed separately by the foundation.

  • Console: Security → Secret Manager.
  • CLI:
    gcloud secrets list --project "$PROJECT" --filter="name~dolibarr"
    gcloud secrets versions access latest --secret=<admin-password-secret-name> --project "$PROJECT"

See App_CloudRun for injection and rotation details.

E. Networking & ingress

The service is reachable at its run.app URL by default (ingress_settings = "all"). An external HTTPS load balancer with a custom domain, Cloud CDN, and Cloud Armor can be layered on; ingress settings and VPC egress control connectivity.

  • Console: Cloud Run (service URL); Network services → Load balancing.
  • CLI:
    gcloud run services describe <service-name> --region "$REGION" --format='value(status.url)'
    gcloud compute addresses list --project "$PROJECT"

See App_CloudRun.

F. Cloud Logging & Monitoring

Container logs flow to Cloud Logging; Cloud Run and Cloud SQL metrics flow to Cloud Monitoring, with optional uptime checks and alert policies.

  • Console: Logging → Logs Explorer; Monitoring → Dashboards / Alerting.
  • CLI:
    gcloud run services logs read <service-name> --project "$PROJECT" --region "$REGION" --limit 50

3. Dolibarr Application Behaviour

  • First-deploy database setup. The db-init job runs db-init.sh using mysql:8.0-debian. It connects to Cloud SQL (TCP private IP on Cloud Run), idempotently creates the application database, user, and grants, verifies the app user can connect, then shuts down the Auth Proxy sidecar. The job is safe to re-run (execute_on_apply = true, max_retries = 3).
  • First-boot auto-install (no separate migration job). With DOLI_INSTALL_AUTO = 1, the Dolibarr image runs its own installer on first container start, creating the schema in the empty database. On version upgrades the image applies its own upgrade steps at boot.
  • Admin account. The installer creates a super-admin whose username is DOLI_ADMIN_LOGIN (default admin) and whose password is the generated DOLI_ADMIN_PASSWORD secret. Retrieve it before first login.
  • DB env-var aliasing. The platform injects the standard DB_* variables; Dolibarr reads DOLI_DB_*. The wrapper entrypoint aliases them at runtime and prefers the injected DB_* values over the image's baked mysql/dolidb defaults — otherwise the container waits forever for a non-existent host.
  • Health path. Startup probe is TCP on port 80; liveness probe is HTTP GET / (the login page returns 200 with no auth). Allow several minutes on first boot for the installer before the login page is served.
  • DOLI_INSTANCE_UNIQUE_ID is a stable salt. Keep it constant across the life of the deployment; it is used for cron URLs and token signing.
  • Inspect the init job and running config:
    gcloud run jobs list --project "$PROJECT" --region "$REGION" --filter="metadata.name~dolibarr"
    gcloud run jobs executions list --job <job-name> --project "$PROJECT" --region "$REGION"
    gcloud run services describe <service-name> --region "$REGION" \
    --format='value(spec.template.spec.containers[0].env)'

4. Configuration Variables

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

Group 3 — Application Identity

VariableDefaultDescription
application_namedolibarrBase name for resources. Do not change after first deploy.
application_versionlatestdolibarr/dolibarr image tag used as the custom-build base; latest is pinned to a known-good tag (23.0.3) at build time.
php_memory_limit512MPHP memory limit; raise for heavy modules/large document libraries.
upload_max_filesize / post_max_size64MMax upload / POST size; keep post_max_size ≥ upload_max_filesize.

Group 4 — Runtime & Scaling

VariableDefaultDescription
container_image_sourcecustomDolibarr ships as a thin custom build; keep custom.
cpu_limit1000m1 vCPU minimum for Dolibarr + MySQL.
memory_limit2GiMinimum 512Mi; 2Gi recommended for production.
min_instance_count0Scale-to-zero; set 1 to avoid cold starts.
max_instance_count1Keep at 1 unless multi-instance sharing is verified.
container_port80Dolibarr runs on Apache, port 80.
enable_cloudsql_volumefalsefalse = TCP private-IP connection (Cloud Run default).

Group 11 — Storage & Filesystem

VariableDefaultDescription
enable_nfstrueNFS is on by default so uploaded documents persist.
nfs_mount_path/var/lib/dolibarrWhere Dolibarr stores documents/PDFs.
storage_buckets[{ name_suffix = "data" }]Additional bucket beyond the auto-provisioned dolibarr-documents bucket, which the Common layer injects via module_storage_buckets.

Group 12 — Database Backend

VariableDefaultDescription
database_typeMYSQL_8_0Fixed engine — Dolibarr requires MySQL.
db_namedolibarrDatabase name. Immutable after first deploy.
db_userdolibarrApplication database user; password auto-generated in Secret Manager.

Group 14 — Observability & Health

VariableDefaultDescription
startup_probeTCP port 80, 30s delay, 20 retriesOnly needs the Apache listener to bind.
liveness_probeHTTP / 300s delayLogin page returns 200 unauthenticated.
uptime_check_configdisabled (path = "/")Optional Cloud Monitoring uptime check.

Group 21 — Redis Cache

VariableDefaultDescription
enable_redisfalseOptional object cache; disabled by default.
redis_host / redis_port"" / 6379Redis endpoint when enabled.

All other inputs follow standard App_CloudRun behaviour.


5. Outputs

Returned on a successful deployment — the quickest way to locate and explore the running resources.

OutputDescription
service_nameCloud Run service name.
service_urlDefault run.app URL of the service.
service_locationRegion the service runs in.
stage_servicesStage-specific service URLs (Cloud Deploy).
load_balancer_ip / load_balancer_urlExternal HTTPS load balancer IP / URL (when enabled).
database_instance_nameCloud SQL instance name.
database_name / database_userApplication database name / user.
database_password_secretSecret Manager secret holding the DB password.
database_host / database_portDB endpoint / port.
storage_bucketsCreated Cloud Storage buckets.
network_name / network_exists / regionsVPC network, presence, regions.
container_image / container_registryDeployed image and Artifact Registry repo.
monitoring_enabled / monitoring_notification_channels / uptime_check_namesMonitoring status, channels, uptime checks.
initialization_jobsNames of the setup jobs (db-init).
deployment_id / tenant_id / resource_prefixNaming identifiers.
project_id / project_numberProject identifiers.
cicd_enabled / github_repository_url / github_repository_owner / github_repository_name / cicd_configurationCI/CD status and details.
artifact_registry_repository / cloudbuild_trigger_name / cloudbuild_trigger_idRegistry and build trigger.
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_CloudRun foundation engine, which validates values and combinations at plan time — an invalid container_port, an out-of-range timeout_seconds/backup_retention_days, IAP with no authorized identities, a gen1 runtime with NFS/GCS mounts. 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
database_typeMYSQL_8_0CriticalSelecting a non-MySQL engine breaks the installer and every query.
db_name / db_userSet onceCriticalImmutable after first deploy; renaming recreates the DB/user and orphans all data.
DOLI_INSTANCE_UNIQUE_ID (auto-generated)Never changeCriticalChanging the salt after first boot invalidates signed tokens and cron URLs.
enable_nfstrueHighDisabling it makes uploaded documents/PDFs ephemeral — lost on every container recreation.
max_instance_count1HighRaising it without shared storage + sticky routing risks split sessions, lock contention, and inconsistent document state.
enable_backup_importfalse unless restoringHighEnabling without a valid backup_uri fails the import job.
DOLI_URL_ROOT (auto-set)Actual service URLHighA wrong root URL breaks absolute links and the login redirect.
memory_limit2GiHighBelow 512Mi the PHP/Apache container OOMs under load; gen2 has a 512Mi floor.
DOLI_ADMIN_PASSWORD (auto-generated)Retrieve before first loginMediumNot knowing it locks you out of the first super-admin account until reset via the DB.
ingress_settingsallMediuminternal blocks public access to the Dolibarr UI.
min_instance_count1 for productionMediumScale-to-zero (0) adds cold-start latency on the first request after idle.
enable_cloud_armorenable for productionMediumThe UI is publicly reachable without WAF protection.

For the foundation behaviour referenced throughout — service identity, scaling and concurrency, ingress and load balancing, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC-SC, backups, and image mirroring — see App_CloudRun. Dolibarr-specific application configuration shared with the GKE variant is described in Dolibarr_Common.