Skip to content
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

suggests using docker compose to provision dev dbs #1732

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 3 additions & 5 deletions README.md
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add instructions here for installing Docker and starting the Docker daemon, before calling any of the localdb scripts?

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The PCD SDK is a framework for developing applications that use PCDs for the pro

### Requirements

`passport-server` uses Postgres, and requires Postgres 15 or higher.
`passport-server` uses Postgres, and requires Postgres 15 or higher.

### Environment Variables

Expand All @@ -77,10 +77,8 @@ In the root of this project, execute the following to start the servers and stat
# installs dependencies for all apps and packages in this repository
yarn

# starts local Postgres - you must have Postgres installed for this
# to work properly. in case you want to restart a Postgres instance
# you previously started in this project, you can also run the command
# yarn localdb:restart
# starts a dockerized local Postgres database on port 5432.
# If you want to restart the instance you also can use yarn localdb:restart
yarn localdb:init && yarn localdb:up

# starts all the applications contained in the `/apps` directory of the
Expand Down
3 changes: 2 additions & 1 deletion apps/passport-server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
envs
db
*.ignore
dev-build
dev-build
local-db-data
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3.8'
services:
db:
image: postgres:latest
restart: always
ports:
- "5432:5432"
command: ['postgres', '-cshared_preload_libraries=pg_stat_statements']
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
POSTGRES_DB: your_database
PGDATA: '/data/postgres'
POSTGRES_INITDB_ARGS: '-E UTF8 --locale=C'
volumes:
- ./apps/passport-server/local-db-data:/data/postgres
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
]
},
"scripts": {
"localdb:restart": "yarn localdb:down && yarn localdb:init && yarn localdb:up",
"localdb:init": "bash -c 'rm -rf apps/passport-server/local-db-data/ && initdb -U admin --pwfile=<(echo password) -A password -D apps/passport-server/local-db-data'",
"localdb:up": "pg_ctl -D apps/passport-server/local-db-data -l apps/passport-server/local-db-log start",
"localdb:down": "pg_ctl -D apps/passport-server/local-db-data -l apps/passport-server/local-db-log stop",
"localdb:init": "bash -c 'rm -rf apps/passport-server/local-db-data/ && docker compose up db'",
"localdb:restart": "docker compose restart db",
"localdb:up": "docker compose up db",
"localdb:down": "docker compose down db",
"build": "scripts/build.sh",
"build:packages": "scripts/build.sh --filter=./packages/**/* --filter=!./apps/*",
"dev": "tsx scripts/watch.ts",
Expand Down