Hi! I'm trying to deploy Typesense in GCP Cloud Ru...
# community-help
c
Hi! I'm trying to deploy Typesense in GCP Cloud Run, but is not fully clear on how to obtain the API key. Do I need to set up a cluster on Typesense Cloud even though the intention was to keep things in GCP/Firebase? Thankful for guidance 🙂
k
👋 Are you self hosting Typesense on GCP? @Christian
When you start the Typesense server, you set a master API key via
--api-key
CLI argument (or equivalent config file or environment variable). You can then use this master key to create additional keys with narrower permissions for searching or exposing to the front-end.
c
Hi, yes, the intention is to self-host in GCP using the Docker image. I used the Firebase plugin, which asks for a API key during setup. So if I understand correctly, I would start the instance in Cloud Run and set the key there, and thereafter run the Firebase plugin?
k
Correct, check this self hosting guide: https://typesense.org/docs/guide/install-typesense.html#option-2-local-machine-self-hosting It contains snippets that show how the server is started with a master API key.
c
Great, thank you for the support! 😀
Even though I'm clearly in over my head here... no idea how to run those commands on GCP 🙂
k
Are you using Docker?
You can set environment variables like this for Docker deployment.
Copy code
export TYPESENSE_API_KEY=xyz

mkdir /tmp/typesense-data

docker run -p 8108:8108 -v/tmp/typesense-data:/data typesense/typesense:0.22.2 \
  --data-dir /data --api-key=$TYPESENSE_API_KEY --enable-cors
c
Yes, but the Docker image has already been pushed to the artefact registry in GCP for deployment, and this looks like commands on a local machine, which makes me somewhat confused.
k
I'm sure GCP will allow you to pass environment variables to the Docker container for configuration.
c
Ok, will investigate. Thanks again! 🙂
c
Could you maybe hint on how to enter these variables into CR? For example, how does one handle the directory creation in this context? And is the API key entered as a secret? Thanks in advance, and sorry for basic questions. I'm somewhat of a newbie.
k
I'm afraid I'm not familiar with the GCP ecosystem apart from the basics. This is not anything specific to Typesense so I think posting on Stackoverflow should get you quick help. I would love to help here but my own knowledge is limited on GCP.
c
Ok, thanks anyway 🙂
Just to follow up and conclude this thread; I assume that the Typesense Docker container is stateful, so it will have to be run in Kubernetes instead of Cloud Run, which only handles stateless services. It's a continuous learning process 🙂
👍 1
k
👍
n
Thanks @Christian for sharing your findings. Been on the same rabbit hole.