Skip to content

Commit 0fb38ae

Browse files
committed
docs(nebraska): add docker exec option for postgres setup
1 parent 27f01fc commit 0fb38ae

1 file changed

Lines changed: 38 additions & 11 deletions

File tree

content/docs/latest/updates-releases/nebraska/development.md

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,48 @@ environment variable `NEBRASKA_DB_URL`.
2525
For a quick setup of `PostgreSQL` for Nebraska's development, you can use
2626
the `postgres` container as follows:
2727

28-
- Start `Postgres`:
29-
- `docker run --rm -d --name nebraska-postgres-dev -p 5432:5432 -e POSTGRES_PASSWORD=nebraska postgres`
28+
- Start `Postgres` and wait until it is ready to accept connections:
3029

31-
- Create the database for Nebraska (by default it is `nebraska`):
32-
- `psql postgres://postgres:nebraska@localhost:5432/postgres -c 'create database nebraska;'`
30+
```bash
31+
docker run --rm -d --name nebraska-postgres-dev -p 5432:5432 -e POSTGRES_PASSWORD=nebraska postgres
3332

34-
- Set the timezone to Nebraska's database:
35-
- `psql postgres://postgres:nebraska@localhost:5432/nebraska -c 'set timezone = "utc";'`
33+
# Wait until Postgres is ready to accept connections (timeout after ~60s)
34+
for i in {1..60}; do
35+
docker exec nebraska-postgres-dev pg_isready -U postgres >/dev/null 2>&1 && break
36+
sleep 1
37+
done
38+
docker exec nebraska-postgres-dev pg_isready -U postgres >/dev/null 2>&1 || { echo "Postgres did not become ready within 60s"; exit 1; }
39+
```
3640

37-
- Set up the nebraska_tests database for running unit tests
41+
- Initialize the databases (`nebraska` and `nebraska_tests`) using either of the following methods:
3842

39-
```bash
40-
psql postgres://postgres:nebraska@localhost:5432/postgres -c 'create database nebraska_tests;'
41-
psql postgres://postgres:nebraska@localhost:5432/nebraska_tests -c 'set timezone = "utc";'
42-
```
43+
- **Option A: Using local `psql`** (if you have `psql` installed on your host machine):
44+
45+
```bash
46+
# Create the database for Nebraska (by default it is `nebraska`)
47+
psql postgres://postgres:nebraska@localhost:5432/postgres -c 'create database nebraska;'
48+
49+
# Set the timezone to Nebraska's database
50+
psql postgres://postgres:nebraska@localhost:5432/nebraska -c "alter database nebraska set timezone to 'utc';"
51+
52+
# Set up the nebraska_tests database for running unit tests
53+
psql postgres://postgres:nebraska@localhost:5432/postgres -c 'create database nebraska_tests;'
54+
psql postgres://postgres:nebraska@localhost:5432/nebraska_tests -c "alter database nebraska_tests set timezone to 'utc';"
55+
```
56+
57+
- **Option B: Using `docker exec`** (run directly inside the container without requiring local PostgreSQL tools):
58+
59+
```bash
60+
# Create the database for Nebraska (by default it is `nebraska`)
61+
docker exec nebraska-postgres-dev psql -U postgres -c "create database nebraska;"
62+
63+
# Set the timezone to Nebraska's database
64+
docker exec nebraska-postgres-dev psql -U postgres -c "alter database nebraska set timezone to 'utc';"
65+
66+
# Set up the nebraska_tests database for running unit tests
67+
docker exec nebraska-postgres-dev psql -U postgres -c "create database nebraska_tests;"
68+
docker exec nebraska-postgres-dev psql -U postgres -c "alter database nebraska_tests set timezone to 'utc';"
69+
```
4370

4471
## Development Quickstart
4572

0 commit comments

Comments
 (0)