@flamber, thanks for suggestions. Some attempts:
Have you tried
%3Ainstead of colon
Yes. I set MB_DB_CONNECTION_URL to postgres://user:pwd@/dbname?host=/cloudsql/project%3Aregion%3Aproject/, but Metabase seems to ignore this and reverts to H2 without throwing any exceptions.
That looks like you can make a string like this:
MB_DB_CONNECTION_URI="postgres://<MY-DB-USER>:<MY-DB-PASS>@/<MY-DB>?cloudSqlInstance='<MY-PROJECT>:<INSTANCE-REGION>:<MY-DATABASE>'&socketFactory=com.google.cloud.sql.mysql.SocketFactory
I think this works if you've included the relevant Google Cloud libraries in the jar itself, but I don't know how to do that.
...but maybe you could do a workaround with a TCP forward
This worked for me, finally!
I made my own Dockerfile like this:
FROM metabase/metabase
RUN apk update
RUN apk add --no-cache socat
# Set up symlink to Cloud SQL UNIX socket
RUN ln -s /cloudsql/<instance-name-goes-here>/.s.PGSQL.5432 pg.sock
COPY startup.sh startup.sh
RUN chmod +x startup.sh
ENTRYPOINT ["./startup.sh"]
... where ./startup.sh looks like:
#! /bin/bash
# Forward TCP:5432 to Cloud SQL Unix socket
nohup socat -d -d TCP4-LISTEN:5432,fork UNIX-CONNECT:pg.sock &
# Runs Metabase
/app/run_metabase.sh
I still had to use a symlink because even socat can't handle paths that contain :.