2

After deploying Metabase in Gcloud, GAE app url shows error page.

I followed all the instructions on this link https://www.cloudbooklet.com/install-metabase-on-google-cloud-with-docker-app-engine/ to deploy metabase on GAE.

I have tried with both mysql and Postgres db but the result is always an error page

Here is my App.yaml code.

env: flex

manual_scaling:
   instances: 1

env_variables:
   MB_JETTY_PORT: 8080
   MB_DB_TYPE: postgres
   MB_DB_DBNAME: metabase
   MB_DB_PORT: 5432
   MB_DB_USER: root
   MB_DB_PASS: password
   MB_DB_HOST: 127.0.0.1

beta_settings:
   cloud_sql_instances: <sql_instance>=tcp:5432

Here is my dockerfile

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 <sql_instance>=tcp:5432
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.33.2/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

Following is the error I get on console log

INFO metabase.driver :: Registered abstract driver :sql  ?

Also the error message on App engine URL says the following,

Error: Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.

I tried all options I could find, please help me with a working solution.

  • Google App Engine was working for me not long ago, but now I'm getting errors with the newest version of Metabase. Have there been changes to how App Engine functions? Did you ever figure this out? – Mike Karp Oct 02 '19 at 16:28
  • I followed the same instruction and getting the exact error you are encountering. I updated the metabase download URL to the latest version, 0.39.3, and still getting the error. Did you solve it? – Hamed MP Jun 02 '21 at 10:16

1 Answers1

0

First, start by following the instructions on the Connecting from App Engine page. Make sure that the SQL Admin API is enabled, and that the service account being used has the Cloud SQL Connect IAM role.

Second, you don't need to run the proxy in the docker container. When you specify it in the app.yml, it allows you to access it on 172.17.0.1:<PORT>. (Although if you are using a container, I would highly suggest you try Cloud Run instead).

Finally, according to this Metabase setup instructions, you need to provide the environment variables to the container to specify what database you want it to use. These env vars are all in format MB_DB_*.

Here is what a dockerfile without the proxy might look like:

FROM gcr.io/google-appengine/openjdk


ENV MB_JETTY_PORT 8080

ENV MB_DB_TYPE postgres
ENV MB_DB_HOST 172.17.0.1
ENV MB_DB_PORT 5432
ENV MB_DB_USER <your-username>
ENV MB_DB_PASS <your-password>
ENV MB_DB_DBNAME <your-database>

ENV JAVA_OPTS "-XX:+IgnoreUnrecognizedVMOptions -Dfile.encoding=UTF-8 --add-opens=java.base/java.net=ALL-UNNAMED --add-modules=java.xml.bind"

ENTRYPOINT java -jar ./metabase.jar

For bonus points, you might consider using the distroless container (gcr.io/distroless/java:11) as a base instead (especially if you switch to Cloud Run).

kurtisvg
  • 3,412
  • 1
  • 8
  • 24