Skip to main content

How to use Postgres

By default, Harness Open Source writes an SQLite database beneath /data in the running container.

You can configure Harness Open Source to use an external Postgres database.

Configuration

To configure Harness Open Source to use your Postgres database, set the GITNESS_DATABASE_DRIVER and GITNESS_DATABASE_DATASOURCE environment variables when you launch your Harness Open Source 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.