Merge pull request #1624 from omnivore-app/add-demo-user

Add demo user in docker-compose migrate service
This commit is contained in:
Hongbo Wu
2023-01-09 09:32:29 +08:00
committed by GitHub
3 changed files with 8 additions and 2 deletions

View File

@ -21,7 +21,7 @@ services:
context: .
dockerfile: ./packages/db/Dockerfile
container_name: "omnivore-migrate"
command: '/bin/sh ./packages/db/setup.sh'
command: '/bin/sh ./packages/db/setup.sh' # Also create a demo user with email: demo@omnivore.app, password: demo
environment:
- PGPASSWORD=postgres
- PG_HOST=postgres

View File

@ -8,7 +8,7 @@ COPY tsconfig.json .
COPY /packages/db/package.json ./packages/db/package.json
RUN apk --no-cache --virtual build-dependencies add postgresql
RUN apk --no-cache --virtual build-dependencies add postgresql uuidgen
RUN yarn install

View File

@ -5,3 +5,9 @@ echo "created app_user"
yarn workspace @omnivore/db migrate
psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "GRANT omnivore_user TO app_user;"
echo "granted omnivore_user to app_user"
# create demo user with email: demo@omnivore.app, password: demo
USER_ID=$(uuidgen)
PASSWORD='$2a$10$nxdWohvkWWpmQ28aTq0BK./pRgt6/WDrWyArvod8uWqxpFu/cfVoy'
psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "INSERT INTO omnivore.user (id, source, email, source_user_id, name, password) VALUES ('$USER_ID', 'EMAIL', 'demo@omnivore.app', 'demo@omnivore.app', 'Demo User', '$PASSWORD'); INSERT INTO omnivore.user_profile (user_id, username) VALUES ('$USER_ID', 'demo');"
echo "created demo user with email: demo@omnivore.app, password: demo"