Skip to main content

How to use Postgres

By default, Gitness writes an SQLite database beneath /data in the running container.

You can configure Gitness to use an external Postgres database.

Configuration

To configure Gitness to use your Postgres database, set the GITNESS_DATABASE_DRIVER and GITNESS_DATABASE_DATASOURCE environment variables when you launch your Gitness container.

For example:

docker run -d \
-e GITNESS_DATABASE_DRIVER=postgres \
-e GITNESS_DATABASE_DATASOURCE="host=1.2.3.4 port=5678 sslmode=disable dbname=gitness user=$USER password=$PASSWORD" \
-p 3000:3000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $HOME/gitness:/data \
--name gitness \
--restart always \
harness/gitness

GITNESS_DATABASE_DRIVER must be postgres.

GITNESS_DATABASE_DATASOURCE is the database connection string according to your Postgres server configuration. For more information on constructing this string, go to the Postgres driver documentation.