Postgres
Coder ships with a built-in PostgreSQL database, but if you'd like to set up and use your own, refer to the following instructions.
For in-depth information, please see the PostgreSQL documentation.
Step 1: Install and start PostgreSQL
macOS with Homebrew
-
Install with Homebrew:
brew install postgres
-
Start PostgreSQL with brew
brew services start postgresql
-
Connect to PostgreSQL:
psql postgres
Debian/Ubuntu
-
Install PostgreSQL:
sudo apt-get install -y postgresql
-
Start PostgreSQL:
sudo systemctl enable postgresql sudo systemctl start postgresql
-
Connect to PostgreSQL:
sudo -u postgresql psql
Step 2: Create a database and user for Coder
-
Create the
coderuser
role:create role coderuser with login;
-
Create a database called
coder
and assign the owner:create database coder owner coder;
-
Set the password for
coderuser
:\password coder # enter password when prompted
-
Assign rights to the database to your user:
grant all privileges on database coder to coderuser;
Using your PostgreSQL database with Coder
To use your Postgres database with Coder, provide the CODER_PG_CONNECTION_URL
variable:
postgresql://[user[:password]@][networkLocation][:port][/dbname][?param1=value1&...]
Append to coder server
to start your deployment. For example:
CODER_PG_CONNECTION_URL="postgres://<databaseUsername>@0.0.0.0/<databaseName>?sslmode=disable&password=<password>" \
coder server -a 0.0.0.0:3000 --verbose
If you installed Coder manually, you can add the
CODER_PG_CONNECTION_URL
variable to/etc/coder.d/coder.env
.
See an opportunity to improve our docs? Make an edit.
On this page