node.jsfirebasefirebase-admindeploying

Firebase creditentials.json file in Github?


I have a Nodejs server with Firebase Admin. I am now confused as to how to have the Credentials ready in my github or anywhere when I want to host my server. In the Firebase docs they explicitly recommend using export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/service-account-file.json" which doesn't make any sense in production environment as you cannot commit this file to github and you cannot deploy it as is (especially if you use github to build your image and deploy that). So what is the common practice in this case? How do I get my credentials when deploying the server?


Solution

  • This will mainly depend on the tools you use to deploy and run your applications. If running on Kubernetes, you can use Secrets to mount the json file on your containers. Docker and Docker Swarm provide similar capabilities. Ideally, the json file should never be permanently packaged into images. They should almost always be securely mounted/wired at runtime.