Skip to content
Splitgraph driver Docker image packaging
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build_scripts
etc/postgresql
init_scripts
splitgraph @ e97617a
.gitmodules
Dockerfile
README.md

README.md

Splitgraph Driver

A normal Splitgraph installation consists of two components: the Splitgraph driver and the Splitgraph client, which talks to the driver. The driver is a docker image which is built from the Dockerfile in this repository.

The basic idea is to run the driver with specific credentials and db name (see below) and to make sure the client is configured with those same credentials.

The published docker image can be found on Docker hub at splitgraph/driver

What's Inside

Currently, the driver is based on the official Docker postgres image, and performs a few additional tasks necessary for running splitgraph and mounting external databases (only mongo and postgres at the moment):

Running the driver

Simply use docker run, or alternatively docker-compose.

For example, to run with forwarding from the host port 5432 to the splitgraph/driver image using password supersecure, default user clientuser, and database cachedb (see "environment variables"):

Via docker run:

docker run -d \
    -e POSTGRES_PASSWORD=supersecure \
    -p 5432:5432 \
    splitgraph/driver

Via docker-compose:

driver:
  image: splitgraph/driver
  ports:
    - 5432:5432
  environment:
    - POSTGRES_PASSWORD=supersecure

And then simply run docker-compose up -d driver

Important: Make sure that your splitgraph client is configured to connect to the driver using the credentials and port supplied when running it.

Environment variables

All of the environment variables documented in the official Docker postgres image apply to the driver. At the moment, there are no additional environment variables necessary. Specifically, the necessary environment variables:

  • POSTGRES_USER: Defaults to clientuser
  • POSTGRES_DB: Defaults to cachedb
  • POSTGRES_PASSWORD: Must be set by you

Extending the driver

Because splitgraph/driver is based on the official docker postgres image, it behaves in the same way as documented on Docker Hub. Specifically, the best way to extend it is to add .sql and .sh scripts to /docker-entrypoint-initdb.d/. These files are executed in executed in sorted name order as defined by the current locale. If you would like to run your files after splitgraph init scripts, see the scripts in the init_scripts directory. Splitgraph prefixes scripts with three digit numbers starting from 000, 001, etc., so you should name your files accordingly.

You can either add these scripts at build time (i.e., create a new Dockerfile that builds an image based on splitgraph/driver), or at run time by mounting a volume in /docker-entrypoint-initdb.d/.

Important Note: No matter which method you use (extending the image or mounting a volume), Postgres will only run these init scripts on the first run of the container, so if you want to add new scripts you will need to docker rm the container to force the initialization to run again.

Note on building the driver: The Splitgraph command line client and library is imported in this repository as a Git submodule in the directory splitgraph. Do git submodule update before building the Docker image to fetch it. If you wish to install a different version of Splitgraph into the driver (note this is only relevant for layered querying, as normal Splitgraph functionality is driven by the sgr command line client), you can either check out a different commit in the submodule or copy your development version into splitgraph.

Adding additional init scripts at build time by creating a new image

Here is an example Dockerfile that extends splitgraph/driver and performs some setup before and after the splitgraph init:

FROM splitgraph/driver

# Use 0000_ to force sorting before splitgraph 000_
COPY setup_before_splitgraph.sql /docker-entrypoint-initdb.d/0000_setup_before_splitgraph.sql

# Do not prefix with digits to force sorting after splitgraph xxx_
COPY setup_after_splitgraph.sql /docker-entrypoint-initdb.d/setup_after_splitgraph.sql

Then you can just build it and run it as usual (see "Running the driver"):

docker build . -t my-splitgraph-driver

Adding additional init scripts at run time by mounting a volume

Just mount your additional init scripts in /docker-entrypoint-initdb.d/ the same as you would if you were adding them at build time (same lexiographical rules apply):

Via docker run:

docker run -d \
    -v "$PWD/setup_before_splitgraph.sql:/docker-entrypoint-initdb.d/0000_setup_before_splitgraph.sql" \
    -v "$PWD/setup_after_splitgraph.sql:/docker-entrypoint-initdb.d/setup_after_splitgraph.sql" \
    -e POSTGRES_PASSWORD=supersecure \
    -p 5432:5432 \
    splitgraph/driver

Via docker compose:

driver:
  image: splitgraph/driver
  ports:
    - 5432:5432
  environment:
    - POSTGRES_PASSWORD=supersecure
  expose:
    - 5432
  volumes:
      - ./setup_before_splitgraph.sql:/docker-entrypoint-initdb.d/0000_setup_before_splitgraph.sql
      - ./setup_after_splitgraph.sql:/docker-entrypoint-initdb.d/setup_after_splitgraph.sql

And then docker-compose up -d driver

More help

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.