diff --git a/README.md b/README.md index d5251a2967..7a8ad4a5dc 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/apps/passport-server/.gitignore b/apps/passport-server/.gitignore index 9003b49318..4dd6848db0 100644 --- a/apps/passport-server/.gitignore +++ b/apps/passport-server/.gitignore @@ -4,4 +4,5 @@ envs db *.ignore -dev-build \ No newline at end of file +dev-build +local-db-data \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..aa681c441c --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/package.json b/package.json index 8ed981a411..21b1887e12 100644 --- a/package.json +++ b/package.json @@ -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",