|
| 1 | +# Doltgres is Dolt for Postgres! |
| 2 | + |
| 3 | +From the creators of [Dolt](https://www.doltdb.com), the world's first version-controlled SQL |
| 4 | +database, comes [Doltgres](https://www.doltgres.com), the Postgres-flavored version of Dolt. It's a |
| 5 | +SQL database that you can branch and merge, fork and clone, push and pull, just like a Git |
| 6 | +repository. Connect to your Doltgres server just like any Postgres database to read or modify schema |
| 7 | +and data. Version control functionality is exposed in SQL via system tables, functions, and |
| 8 | +procedures. |
| 9 | + |
| 10 | +Git versions file, Doltgres versions tables. It's like Git and Postgres had a baby. |
| 11 | + |
| 12 | +[Join us on Discord](https://discord.com/invite/RFwfYpu) to say hi and |
| 13 | +ask questions, or [check out our roadmap](https://docs.dolthub.com/other/roadmap) |
| 14 | +to see what we're building next. |
| 15 | + |
| 16 | +## What's it for? |
| 17 | + |
| 18 | +Lots of things! Doltgres is a generally useful tool with countless applications. But if you want |
| 19 | +some ideas, [here's how people are using it so |
| 20 | +far](https://www.dolthub.com/blog/2022-07-11-dolt-case-studies/). |
| 21 | + |
| 22 | +# How to use this image |
| 23 | + |
| 24 | +This image is for the Doltgres server and is similar to the Postgres Docker image. Running this |
| 25 | +image without any arguments is equivalent to running the `doltgres` command inside a Docker |
| 26 | +container. |
| 27 | + |
| 28 | +To see all supported options for `doltgres`, you can run the image with `--help` flag. |
| 29 | + |
| 30 | +```shell |
| 31 | +$ docker run dolthub/doltgresql:latest --help |
| 32 | +``` |
| 33 | + |
| 34 | +## Building the image |
| 35 | + |
| 36 | +To build this image, use the `Dockerfile` in the root of the [Doltgres |
| 37 | +repository](https://github.com/dolthub/doltgresql/) with an optional build argument: |
| 38 | + |
| 39 | +```shell |
| 40 | +# Build the latest Doltgres version (automatically fetches the latest release) |
| 41 | +$ docker build -t doltgres:latest . |
| 42 | + |
| 43 | +# Build the latest Doltgres version (fetches the latest release) |
| 44 | +$ docker build --build-arg DOLTGRES_VERSION=latest -t doltgres:latest . |
| 45 | + |
| 46 | +# Build with a specific Doltgres version |
| 47 | +$ docker build --build-arg DOLTGRES_VERSION=0.55.1 -t doltgres:0.55.1 . |
| 48 | + |
| 49 | +# Build from local source code |
| 50 | +$ docker build --build-arg DOLTGRES_VERSION=source -t doltgres:source . |
| 51 | +``` |
| 52 | + |
| 53 | +## Connect to the server in the container from the host system |
| 54 | + |
| 55 | +To connect to a server running in a container from the host system, we need to map a port on the |
| 56 | +host system to the port our server is running on in the container. |
| 57 | + |
| 58 | +```bash |
| 59 | +$ docker run -p 5432:5432 dolthub/doltgresql:latest |
| 60 | +``` |
| 61 | + |
| 62 | +*Note*: if you have Postgres installed on this machine already, port `5432` will be in use. Either |
| 63 | +choose a different port to map or shut down Postgres. |
| 64 | + |
| 65 | +Now connect with `psql` or another Postgres-compatible client. |
| 66 | + |
| 67 | +```bash |
| 68 | +$ PGPASSWORD=password psql --host 127.0.0.1 -U postgres |
| 69 | +``` |
| 70 | + |
| 71 | +## Define configuration for the server |
| 72 | + |
| 73 | +You can specify server configuration by providing your own `config.yaml` for the server to use as a |
| 74 | +mounted volume. The image looks for a `config.yaml` file in the mounted directory |
| 75 | +`/etc/doltgres/servercfg.d`. Place your desired `config.yaml` directory in a local file, then |
| 76 | +provide it to `docker run` with the `-v` argument like this: |
| 77 | + |
| 78 | +```shell |
| 79 | +$ docker run -v ./doltgres_cfg:/etc/doltgres/servercfg.d -p 5432:5432 dolthub/doltgresql:latest |
| 80 | +``` |
| 81 | + |
| 82 | +The data directory in the container is `/var/lib/doltgresql/`. To change this, provide the `PGDATA` |
| 83 | +or `DOLTGRES_DATA` environment variable to `docker run`. This directory can also be a mounted |
| 84 | +directory on the local machine. |
| 85 | + |
| 86 | +```shell |
| 87 | +$ docker run -e PGDATA=/path/to/doltgres/data -p 5432:5432 dolthub/doltgresql:latest |
| 88 | +``` |
| 89 | + |
| 90 | +## Specifying a username and password |
| 91 | + |
| 92 | +By default, the server creates a super-user named `postgres` with the password `password`. To change |
| 93 | +this, provide the `DOLTGRES_USER` and `DOLTGRES_PASSWORD` environment variables to the `docker run` |
| 94 | +command. |
| 95 | + |
| 96 | +```shell |
| 97 | +$ docker run -e DOLTGRES_USER=myuser -e DOLTGRES_PASSWORD=mypass -p 5432:5432 dolthub/doltgresql:latest |
| 98 | +``` |
| 99 | + |
| 100 | +For convenience, `POSTGRES_USER` and `POSTGRES_PASSWORD` are accepted as aliases for these variables. |
| 101 | + |
| 102 | +To create additional users, connect to the running database and issue `CREATE ROLE` and `GRANT` |
| 103 | +statements as the super-user. |
| 104 | + |
| 105 | +## Environment Variables |
| 106 | + |
| 107 | +The Doltgres image supports the following environment variables: |
| 108 | + |
| 109 | +- `DOLTGRES_USER`: The name of the super-user (default: `postgres`). `POSTGRES_USER` is an alias. |
| 110 | +- `DOLTGRES_PASSWORD`: The password for the super-user (default: `password`). `POSTGRES_PASSWORD` is |
| 111 | + an alias. |
| 112 | +- `DOLTGRES_DATA`: Specifies a path in the container to store database data, created if it doesn't |
| 113 | + exist (default: `/var/lib/doltgresql/`). `PGDATA` is an alias. |
| 114 | +- `DOLTGRES_DB`: Specifies a database name to be created (default: none). The `postgres` database is |
| 115 | + still created. |
0 commit comments