Installing plugins (Oracle driver) on an AWS EB instance

Hi all!

I’ve done a lot of searching & even considered modifying the config files for Elastic Beanstalk, but before I get into all of that I was wondering if anyone had any experience in installing plugins (specifically the Oracle driver) on an AWS EB install of Metabase.

I can reinstall on a traditional server, but I’d really love to figure it out on EB first. Thanks in advance for any advice y’all can provide!

Hi @nbentley
I don’t use AWS, but you can push the environment variable MB_PLUGINS_DIR to docker, which you should be able to point to a mapped volume.

@flamber thanks for getting back so quickly! I’ll play around with this and see if I can get it to work.

EDIT: If in the future someone has a better way to do this, please do reply to this thread.

Got it working, but through a modification of a couple files & by pulling the development version from Docker Hub (not great, but necessary since a fix for the plugins folder was pushed & isn’t available in the most recent docker release). Essentially, I changed the Dockerrun.aws.json file to map a volume that I added in the Metabase setup script that runs on the instance.

Dockerrun.aws.json

{
"AWSEBDockerrunVersion": "1",
"Volumes": [
{
  "HostDirectory": "/etc/dbdrivers",
  "ContainerDirectory": "/app/plugins"
}
],
"Image": {
"Name": "metabase/metabase-head:latest",
"Update": "true"
},
"Ports": [
{
  "ContainerPort": "3000"
}
],
"Logging": "/var/log/metabase"
}

.ebextensions/metabase_config/metabase-setup.sh

added

# add the oracle driver
metabase_pluginsdir () {
mkdir /etc/dbdrivers && cd /etc/dbdrivers
wget -q "accessible-oracle-driver-url"
}

and added

metabase_pluginsdir)
     metabase_pluginsdir
     ;;

to the case statement at the bottom.

Very hacky & hopefully in the future this is made a bit easier, but this way does ensure that when you deploy a new version or reprovision the instance the driver will deploy with it.

1 Like

This is not necessarily a better way, but just a slight variation from OP’s solution that does not require a “accessible-oracle-driver-url”. So if you have a copy of ojdbcX.jar, but not sure how to serve it over a url, then this will be easier for you.

First, you need the EB deployment .zip file for metabase. If you already deployed base install to EB, then you can download from Application Versions. Or you can find link to it on Metabase documentation page for running Metabase on Elastic Beanstalk under the Deploying new versions of Metabase section.

Unzip it to metabase-aws-eb/. In the same folder save your copy of ojdbcX.jar. It should be at same level as the Dockerrun.aws.json file.

Edit Dockerrun.aws.json same way OP did to add the Volumes

  "Volumes": [
  {
    "HostDirectory": "/opt/plugins", "ContainerDirectory": "/plugins"
  }
  ]

The host location is up to you as there is no standard that I am aware of. I chose /opt/plugins.

For those like me who are not Docker experts: This will mount the file location of /opt/plugins on the EC2 instance to /plugins in the Docker container that is running on the EC2 instance.

The choice of /plugins for the container is because that is the default plugin location Metabase uses for docker deployments.

This by itself is not enough. We still need EB to automatically create the /opt/plugins folder and place the ojdbcX.jar file in it whenever it deploys a new EC2 instance.

EB advanced configurations use the .ebextensions folder which you should notice is also in metabase-aws-eb/. Edit the file 01_metabase.config and add the following container commands to the end of the list (but before the option settings).

    06_plugins:
        command: "mkdir /opt/plugins && chmod 777 /opt/plugins"
        ignoreErrors: true
        
    07_install_oracle_driver:
        command: "cp ojdbc6.jar /opt/plugins"
        ignoreErrors: true

Obviously, if you chose a different path, replace references to /opt/plugins. Keep in mind this is YAML syntax so indentation matters.

Now re-zip the files you unzipped including the Oracle driver. Upload zip file to EB as a new Application Version and deploy it.

Again for the those of us not Docker experts: Whenever a new EC2 instance or application version is deployed, the contents of metabase-aws-eb.zip are extracted to /var/app/current/ on the EC2 instance. This now includes our Oracle driver we packaged. Before the application is started, these container commands will be run on the EC2 instance (not within the container). So this creates the /opt/plugins directory we specified for the HostDirectory, then copies the Oracle driver to that directory. The chmod command is to make sure the Docker process can also write to this directory as all these container commands are executed as root user. This is needed for our case because when Metabase deploys it unpacks several .jar files to the same /plugins folder inside the container.

You can verify Oracle driver was properly installed by either attempting to set up an Oracle database in Metabase or check the Metabase logs in the Admin section under Troubleshooting.

1 Like