Purpose
Trilium can be used as a personal knowledge base. It can be run locally or synchronized across multiple devices as a server. By using google cloud run as the server, we can have a reliable and scalable solution with the following advantages.
- Cost-effective: Cloud Run is serverless. So no hassles of maintaining a server or VM. We pay only for the resources used. We can scale the number of nodes to zero when not in use.
- Storage: A recent feature of Cloud Run is the ability to mount a google cloud storage bucket as a volume.
Steps
# set the project name and region. Change these values as per your requirement
export PROJECT_ID=project_xyz
export REGION=asia-southeast1
export BUCKET_NAME=bucket_name
# switch to the project
gcloud config set project $PROJECT_ID
# create a cloud storage bucket
gsutil mb -l $REGION gs://$BUCKET_NAME
# deploy trilium to cloud run
gcloud beta run deploy trilium --image zadam/trilium:0.63-latest \
\
--execution-environment gen2 $BUCKET_NAME \
--add-volume=name=trilium_data,type=cloud-storage,bucket=\
--add-volume-mount=volume=trilium_data,mount-path=/home/node/trilium-data --max-instances 1 \
--allow-unauthenticated \
--memory 512Mi $REGION --project $PROJECT_ID --region
Once deployment is successful, we get a url in shell, something like https://trilium-xyz1234-as.a.run.app
Access
- Open the url in a browser. Now you can set a strong password and start using trilium.