Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: docker-db/up
docker-db/up:
docker compose -f docker-compose.dev.yaml down
docker compose -f docker-compose.dev.yaml up

.PHONY: docker-db/down
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
Using Docker compose, you can skip the database migration steps for testing and development.

The database will be bound to `localhost:5432`.
```sh
# start/restart
make docker-db/up

# stop
make docker-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