Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.local
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CORS_ORIGINS=http://localhost:5173,https://example.com
DATABASE_URL=postgres://postgres:postgres@localhost:5432/river_dev
TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/river_test
OTEL_ENABLED=false
PORT=8080
VITE_RIVER_API_BASE_URL=http://localhost:8080/api
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@ verify: verify/sqlc
.PHONY: verify/sqlc
verify/sqlc:
cd internal/dbsqlc && sqlc diff

.PHONY: db/up
db/up:
docker compose -f docker-compose.dev.yaml down
docker compose -f docker-compose.dev.yaml up

.PHONY: db/down
db/down:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you name these something like docker-db/up instead? Don't feel strongly about a specific name, but they should include "docker".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with docker-db/up and docker-db/down

docker compose -f docker-compose.dev.yaml down
37 changes: 37 additions & 0 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: riverui-dev

services:
postgres:
image: "postgres:16-alpine"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
healthcheck:
test: ["CMD", "pg_isready", "-d", "river_dev", "-U", "postgres"]
timeout: 20s
retries: 10
start_period: 3s
volumes:
- ./scripts/docker-compose-dev/postgres/init:/docker-entrypoint-initdb.d
ports:
- "5432:5432"
migrate:
image: "golang:1.24-alpine"
depends_on:
postgres:
condition: "service_healthy"
entrypoint: "/bin/sh"
# cache the go binaries so they don't redownload
volumes:
- gopath:/go
command:
- -c
- |
echo "downloading river binary"
go install github.com/riverqueue/river/cmd/river@latest
echo "migrating river_dev database"
river migrate-up --database-url "postgres://postgres:postgres@postgres/river_dev"
echo "migrating river_test database"
river migrate-up --database-url "postgres://postgres:postgres@postgres/river_test"
volumes:
gopath:
12 changes: 12 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ $ go install github.com/riverqueue/river/cmd/river
$ river migrate-up --database-url postgres://localhost/river_dev
```

## Postgres with docker compose

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the nits here, but lets just make sure to use correct capitalization and punctuation everywhere here:

Suggested change
## Postgres with docker compose
## Postgres with Docker compose

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never upset about consistency and proper documentation. Addressed ^_^

If you decided to use postgres in docker compose, you can skip database migration steps for testing and development

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you decided to use postgres in docker compose, you can skip database migration steps for testing and development
Using Docker compose, you can skip the database migration steps for testing and development.


The database would be accessible through localhost

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this line adds all that much as is. Maybe be specific that the Docker database becomes bound to your local machine at localhost:5432 if that's the case.

```sh
# start/restart
make db/up

# stop
make db/down
```

## Run tests

Raise test database:
Expand Down
2 changes: 2 additions & 0 deletions scripts/docker-compose-dev/postgres/init/01-init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE DATABASE river_dev;
CREATE DATABASE river_test;
Loading