Install Metabase on Google Cloud with Docker on Google App Engine. In this tutorial you are going to learn how to install Metabase and connect it with Cloud SQL with CloudSQL proxy.

This guide demonstrates how to install Java using Docker in App Engine Flexible Environment with app.yaml and Dockerfile which is easily scalable.

Prerequisites

  1. Google Cloud account with billing activated.
  2. Cloud SQL setup as described here Cloud SQL Second Generation Instance.
  3. Enable Cloud SQL and Cloud SQL Admin API.
  4. Install GCloud SDK in your local computer.

Enable APIs and Create New Service account

Go to APIs and Services and click Enable APIs and Services and enable Cloud SQL API and Cloud SQL Admin API

Go to IAM & Admin >> Service accounts and click Create service account.

In step 1

Enter Service account Name.

Click Create.

In step 2

Select Role.

Cloud SQL >> Cloud SQL Admin
Project >> Editor

Click Continue.

In step 3

Click Create Key.

Choose Key type as JSON

Click Create.

Create Cloud SQL Instance

Follow this tutorial to create a new Cloud SQL Second Generation Instance.

Once you have created a user and a database you can proceed to set up the yaml file and Docker file in the local computer.

Setup Cloud SDK

Once you have installed the cloud SDK, run the below command to configure it and choose the project to deploy the Metabase.

Open command prompt or terminal in your local computer and run the following the command.

gcloud init

Follow the onscreen instructions to configure it.

Create Yaml File for Metabase

Create a new directory in your computer named metabase

Open your favorite editor and create a file named app.yaml inside the metabase directory.

Copy the below code and add this in your app.yaml file.

runtime: custom
env: flex

manual_scaling:
   instances: 1

env_variables:
   MB_DB_TYPE: mysql
   MB_DB_DBNAME: cloudsql_db_name
   MB_DB_USER: cloudsql_user_name
   MB_DB_PASS: cloudsql_password
   MB_DB_HOST: 127.0.0.1

beta_settings:
   cloud_sql_instances: cloudsql_connection_name

Replace the cloudsql_db_name, cloudsql_user_name, cloudsql_password, and cloudsql_connection_name with the values of your Cloud SQL instance.

Save your file.

Create Dockerfile for Metabase

Create a new file in the same metabase directory and name it as Dockerfile

Copy the below code and add this in your Docketfile file.

FROM gcr.io/google-appengine/openjdk

EXPOSE 8080

ENV PORT 8080
ENV MB_PORT 8080
ENV MB_JETTY_PORT 8080
ENV MB_DB_PORT 5432
ENV METABASE_SQL_INSTANCE cloudsql_connection_name
ENV JAVA_OPTS "-XX:+IgnoreUnrecognizedVMOptions -Dfile.encoding=UTF-8 --add-opens=java.base/java.net=ALL-UNNAMED --add-modules=java.xml.bind"

ADD https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 ./cloud_sql_proxy
ADD http://downloads.metabase.com/v0.32.9/metabase.jar /metabase.jar

RUN chmod +x ./cloud_sql_proxy

CMD ./cloud_sql_proxy -instances=$METABASE_SQL_INSTANCE=tcp:$MB_DB_PORT & java -jar ./metabase.jar

Replace the cloudsql_connection_name with your Cloud SQL instance connection name.

Save the file.

Deploy Metabase to App Engine

Open terminal in the metabase directory.

Run the following command to deploy Metabase to App Engine.

gcloud app deploy

Now, Metabase will be installed on Google App Engine and connected with Cloud SQL.

Once the deployment is completed you will get the url to view your application on the browser.

Install Metabase on Google Cloud with Docker - App Engine

Conclusion

Now you have learned how to deploy Metabase on Google App Engine Flexible environment.

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Where Writing Meets Entrepreneurship!

Get FREE Google Cloud Tutorials.
GET NOW
close-link
Please help us get 1000 likes in Facebook. Thank You!
LIKE NOW

Stay Connected!

Get latest tutorials on Google Cloud and Open Source topics
SUBSCRIBE
close-link