Gitlab deploy to Firebase

Gitlab deployment script that will deploy to a Firebase app.

Gitlab Firebase Docker Build Image

Create a repo in Gitlab, that will be responsible for building a docker image. This image will be built into the gitlab registry, so it can be used to deploy any Gitlab repo to a Firebase hosting app.

Create a repo called firebase in your Gitlab project.

Create a Dockerfile that will install the latest node version and the command line tools for firebase.

Create a .gitlab-ci.yml to build this image into your projects Gitlab registry.

Change anywhere it says {{ PROJECT_NAME }} to whatever your group or project name is.

Push these files to the master branch of your firebase repo and it will create a build image we can use to deploy any firebase app in our project. Next we will use this newly create image to build and deploy for us.

Gitlab CI/CD Script

Generate the firebase token so Gitlab will know how to deploy our app. On the command line run this command. It will authenticate and generate a new token. Copy the token and add it to your Gitlab Environment variables as FIREBASE_TOKEN

Create a .gitlab-ci.yml file

This script assumes you are running npm builds, but you can add any build steps you want.

To finally deploy the app to firebase the script runs these two lines

Now anytime you push to develop or master branch it will deploy to your Firebase hosting application.

Happy coding!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store