-
Notifications
You must be signed in to change notification settings - Fork 39
Add postgres development database via docker compose #393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
6175d8f
78cc3fa
f928003
561abb9
1ea957c
d592f1f
b6be613
0475238
2632a54
11526b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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: |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| The database would be accessible through localhost | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
| ```sh | ||||||
| # start/restart | ||||||
| make db/up | ||||||
|
|
||||||
| # stop | ||||||
| make db/down | ||||||
| ``` | ||||||
|
|
||||||
| ## Run tests | ||||||
|
|
||||||
| Raise test database: | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| CREATE DATABASE river_dev; | ||
| CREATE DATABASE river_test; |
There was a problem hiding this comment.
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/upinstead? Don't feel strongly about a specific name, but they should include "docker".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went with
docker-db/upanddocker-db/down