Giter VIP home page Giter VIP logo

Comments (10)

pupupulp avatar pupupulp commented on May 12, 2024

Update: I also tried overriding metabase's run_metabase.sh in which i added this line JAVA_OPTS="${JAVA_OPTS} -cp /usr/java/jaybird-full-3.0.6.jar" but still not working though

here is the updated run_metabase.sh file

#!/bin/bash

# if nobody manually set a host to listen on then go with all available interfaces and host names
if [ -z "$MB_JETTY_HOST" ]; then
    export MB_JETTY_HOST=0.0.0.0
fi


# Metabase Database Info - this is just about what db the Metabase application uses for internal storage

# AWS Elastic Beanstalk w/ RDS
if [ ! -z "$RDS_HOSTNAME" ]; then
    # EEK: this is a bit fragile.  if user picks a non-standard port for their db we are screwed :(
    if [ "$MB_DB_PORT" == "3306" ]; then
        export MB_DB_TYPE=mysql
    else
        export MB_DB_TYPE=postgres
    fi

    export MB_DB_DBNAME=$RDS_DB_NAME
    export MB_DB_USER=$RDS_USERNAME
    export MB_DB_PASS=$RDS_PASSWORD
    export MB_DB_HOST=$RDS_HOSTNAME
    export MB_DB_PORT=$RDS_PORT
fi


# Avoid running metabase (or any server) as root where possible
# If you want to use specific user and group ids that matches an existing
# account on the host pass them in $MGID and $MUID when starting metabase
MGID=${MGID:-2000}
MUID=${MUID:-2000}

# create the group if it does not exist
# TODO: edit an existing group if MGID has changed
getent group metabase > /dev/null 2>&1
group_exists=$?
if [ $group_exists -ne 0 ]; then
    addgroup -g $MGID -S metabase
fi

# create the user if it does not exist
# TODO: edit an existing user if MGID has changed
id -u metabase > /dev/null 2>&1
user_exists=$?
if [[ $user_exists -ne 0 ]]; then
    adduser -D -u $MUID -G metabase metabase
fi

db_file=${MB_DB_FILE:-/metabase.db}

# In order to run metabase as a non-root user in docker, we need to handle various
# cases where we where previously ran as root and have an existing database that
# consists of a bunch of files, that are owned by root, sitting in a directory that
# may only be writable by root. It's not safe to simply change the ownership or
# permissions of an unknown directory that may be a volume mounted on the host, so
# we will need to detect this and make a place that is going to be safe to set
# permissions on.

# So first some preliminary checks:

# 1. Does this container have an existing H2 database file?
# 2. or an existing H2 database in it's own directory,
# 3. or neither?


# is there a pre-existing files only database without a metabase specific directory?
if ls $db_file\.* > /dev/null 2>&1; then
    db_exists=true
else
    db_exists=false
fi
# is it an old style file
if [[ -d "$db_file" ]]; then
    db_directory=true
else
    db_directory=false
fi

# If the db exits, and it's just some files in a shared directory we could do
# serious damage to peoples home or /tmp directories if we where to set the
# permissions on that directory to allow metabase to create db-lock and db-part
# file there. To keep them safe we make a new directory with the same name and
# move the db file into the new directory. If we where passed the name of a
# directory rather than a specific file, then we are safe to set permissions on
# that directory so there is no need to move anything.

# an example file would look like /tmp/metabase.db/metabase.db.mv.db
new_db_dir=$(dirname $db_file)/$(basename $db_file)

if [[ $db_exists = "true" && ! $db_directory = "true" ]]; then
    mkdir $new_db_dir
    mv $db_file\.* $new_db_dir/
fi

# and for the new install case we create the directory
if [[ $db_exists = "false" && $db_directory = "false" ]]; then
    mkdir $new_db_dir
fi

# the case where the DB exists and is a directory, there is nothing to do
# so nothing happens here. This will be the normal case.

# next we tell metabase use the files we just moved into the directory
# or create the files in that directory if they don't exist.
export MB_DB_FILE=$new_db_dir/$(basename $db_file)

# TODO: print big scary warning if they are configuring an ephemeral instance

chown metabase:metabase $new_db_dir $new_db_dir/* 2>/dev/null  # all that fussing makes this safe

# Setup Java Options
JAVA_OPTS="${JAVA_OPTS} -XX:+IgnoreUnrecognizedVMOptions"
JAVA_OPTS="${JAVA_OPTS} -Dfile.encoding=UTF-8"
JAVA_OPTS="${JAVA_OPTS} -Dlogfile.path=target/log"
JAVA_OPTS="${JAVA_OPTS} -server"
JAVA_OPTS="${JAVA_OPTS} -cp /usr/java/jaybird-full-3.0.6.jar"

if [ ! -z "$JAVA_TIMEZONE" ]; then
    JAVA_OPTS="${JAVA_OPTS} -Duser.timezone=${JAVA_TIMEZONE}"
fi

# Launch the application
# exec is here twice on purpose to  ensure that metabase runs as PID 1 (the init process)
# and thus receives signals sent to the container. This allows it to shutdown cleanly on exit
exec su metabase -s /bin/sh -c "exec java $JAVA_OPTS -jar /app/metabase.jar $@"

and here is the update Dockerfile

FROM metabase/metabase

ENV FB_DRIVER_URL=https://github.com/evosec/metabase-firebird-driver/releases/download/v1.0/firebird.metabase-driver.jar \
    FB_DRIVER=firebird.metabase-driver.jar \
    PLUGINS_PATH=/plugins   
 
COPY setup-user-group.sh setup-user-group.sh
COPY run_metabase.sh /app/run_metabase.sh

COPY jaybird-3.0.6.jar /usr/java/jaybird-3.0.6.jar
COPY jaybird-full-3.0.6.jar /usr/java/jaybird-full-3.0.6.jar

ENV CLASSPATH "${CLASSPATH}:/usr/java/jaybird-3.0.6.jar"
ENV CLASSPATH "${CLASSPATH}:/usr/java/jaybird-full-3.0.6.jar"

RUN chmod +x /app/run_metabase.sh \
    && chmod +x setup-user-group.sh \
    && ./setup-user-group.sh

RUN wget -O ${PLUGINS_PATH}/${FB_DRIVER} ${FB_DRIVER_URL}

RUN chmod 644 ${PLUGINS_PATH}/${FB_DRIVER} \
    && chown metabase:metabase ${PLUGINS_PATH}/${FB_DRIVER}

ENTRYPOINT ["/app/run_metabase.sh"]

i am really looking forward to make this work since a lot of our databases are in firebird so its a lot helping for the other team if they could utilize Metabase along with firebird through your plugin, thank you so much

from metabase-firebird-driver.

pupupulp avatar pupupulp commented on May 12, 2024

ooff btw I also tried on both firebird 2.5 and 3 but still I cant register a database thank you

from metabase-firebird-driver.

Nikos410 avatar Nikos410 commented on May 12, 2024

Hey there! It looks like metabase can not find the required JDBC driver, Jaybird, which should be included in the firebird.metabase-driver.jar. So, if Metabase can find the driver, it should be able to find Jaybird as well.

Did you try running Metabase without manually including the Jaybird jar as a dependency? Maybe having Jaybird twice confuses Metabase/Java?

What Version of Metabase are you using? Maybe one of the recent updates changed the behaviour of drivers, we are using a Metabase version that is a few months old by now, so that could definetly be possible.

from metabase-firebird-driver.

pupupulp avatar pupupulp commented on May 12, 2024

Yes at first I tried without the Jaybird since i believed its already included within the jar file, but the error showed up

Im using Metabase v0.32.10, could you share your version so that I could try to lower mine and see if it works?

from metabase-firebird-driver.

Nikos410 avatar Nikos410 commented on May 12, 2024

Alright, I don't know which version of Metabase we are using internally and I can't check right now, since I'm not in the office today. But I know for sure that it worked (for us) with the first version that introduced the new modular driver system, 0.32.0. You could try if that version works for you.

from metabase-firebird-driver.

pupupulp avatar pupupulp commented on May 12, 2024

Heyy yes so Im about to say that just right now from the context of your message "a Metabase version that is a few months old by now" I checked their docker hub repo and see their tags, the last version that meets your description is this one v0.32.9 I tried lowering to that version and I think its working now

different error has shown up

java.sql.SQLInvalidAuthorizationSpecException: Your user name and password are not defined. Ask your database administrator to set up a Firebird login. [SQLState:28000, ISC error code:335544472]

which I think is my fault for wrong password entry

thank you so much for the help

from metabase-firebird-driver.

pupupulp avatar pupupulp commented on May 12, 2024

Ok confirmed the working version with Metabase is v0.32.9, this issue is solved now thank you so much for the help, great plugin btw :D :D

from metabase-firebird-driver.

Nikos410 avatar Nikos410 commented on May 12, 2024

@camsaul Do you have an idea what could cause this? Did 0.32.10 change the behaviour of drivers? (I can open an issue in the Metabase Repo if you prefer)

from metabase-firebird-driver.

Nikos410 avatar Nikos410 commented on May 12, 2024

@pupupulp I released a new version of the driver, that should work with the latest version of Metabase

from metabase-firebird-driver.

pupupulp avatar pupupulp commented on May 12, 2024

@Nikos410 this duly noted thank you so much :D

from metabase-firebird-driver.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.