automate database setup and upgrade (#1163)

* Automate database setup and schema upgrade
pull/1172/head
Le_Bleu 2 years ago committed by GitHub
parent 4fd0622114
commit 57a14bd945
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -49,4 +49,4 @@ FROM node:16-alpine
COPY --from=builder /ghostfolio/dist/apps /ghostfolio/apps
WORKDIR /ghostfolio/apps/api
EXPOSE 3333
CMD [ "node", "main" ]
CMD [ "yarn", "start:prod" ]

@ -114,14 +114,6 @@ Run the following command to start the Docker images from [Docker Hub](https://h
docker-compose --env-file ./.env -f docker/docker-compose.yml up -d
```
##### Setup Database
Run the following command to setup the database once Ghostfolio is running:
```bash
docker-compose --env-file ./.env -f docker/docker-compose.yml exec ghostfolio yarn database:setup
```
#### b. Build and run environment
Run the following commands to build and start the Docker images:
@ -131,14 +123,6 @@ docker-compose --env-file ./.env -f docker/docker-compose.build.yml build
docker-compose --env-file ./.env -f docker/docker-compose.build.yml up -d
```
##### Setup Database
Run the following command to setup the database once Ghostfolio is running:
```bash
docker-compose --env-file ./.env -f docker/docker-compose.build.yml exec ghostfolio yarn database:setup
```
#### Fetch Historical Data
Open http://localhost:3333 in your browser and accomplish these steps:
@ -150,8 +134,8 @@ Open http://localhost:3333 in your browser and accomplish these steps:
#### Upgrade Version
1. Increase the version of the `ghostfolio/ghostfolio` Docker image in `docker/docker-compose.yml`
1. Run the following command to start the new Docker image: `docker-compose --env-file ./.env -f docker/docker-compose.yml up -d`
1. Then, run the following command to keep your database schema in sync: `docker-compose --env-file ./.env -f docker/docker-compose.yml exec ghostfolio yarn database:migrate`
1. Run the following command to start the new Docker image: `docker-compose --env-file ./.env -f docker/docker-compose.yml up -d`
At each start container will automatically upgrade database schema if needed.
### Run with _Unraid_ (Community)

@ -17,7 +17,6 @@
"build:dev": "nx run api:build && nx run client:build --localize && yarn replace-placeholders-in-build",
"build:storybook": "nx run ui:build-storybook",
"clean": "rimraf dist",
"database:baseline": "sh ./prisma/baseline.sh",
"database:format-schema": "prisma format",
"database:generate-typings": "prisma generate",
"database:gui": "prisma studio",
@ -42,7 +41,7 @@
"replace-placeholders-in-build": "node ./replace.build.js",
"start": "node dist/apps/api/main",
"start:client": "ng serve client --configuration=development-en --hmr -o",
"start:prod": "node apps/api/main",
"start:prod": "yarn database:migrate && yarn database:seed && node main",
"start:server": "nx serve api --watch",
"start:storybook": "nx run ui:storybook",
"test": "nx test",

@ -1,8 +0,0 @@
#!/bin/sh
# List all migration scripts based on the directory name and mark the migration as "applied"
for directory in ./prisma/migrations/*/; do
migration=$(echo "$directory" | sed 's/.\/prisma\/migrations\///' | sed 's/\///')
yarn prisma migrate resolve --applied $migration
done
Loading…
Cancel
Save