Skip to content

Commit

Permalink
Added DB stuff to dev readme
Browse files Browse the repository at this point in the history
  • Loading branch information
glormph committed Apr 15, 2024
1 parent 7f053a7 commit 730dd22
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ HOST_UPLOADPATH=PATH_TO_YOUR_REPO/data/uploads
HOST_ANALYSISFILES=PATH_TO_YOUR_REPO/data/analysisfiles

# /path/to/your/backups to mount in DB, when you restore it
BACKUP_PATH=
BACKUP_PATH=PATH_TO_YOUR_BACKUPS

# mydomain.example.com for Django allowed-hosts setting
HOST_FQDN=localhost
Expand Down
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ bash src/docker/init_develop.sh
docker compose up
```




## Development:

The backend Django code is mounted in the running web container while developing.
Expand Down Expand Up @@ -56,6 +53,35 @@ export GROUP_ID=$(id -g)
docker compose build
```

## DB content

Kantele uses a postgres database, and the development container has local folders
bind-mounted in the container for persistence, so if the container is removed, the
database will persist. There is also a backup folder mounted (defined in .env
as `BACKUP_PATH`), through which you can deliver SQL dump files.

Creating a database dump:
```
# If you have the containers up:
docker compose exec db pg_dump -U kanteleuser -d kantele -f /pgbackups/file_to_dump_to.sql
# If the containers are down:
docker compose run db pg_dump -U kanteleuser -d kantele -f /pgbackups/file_to_dump_to.sql
```

Installing a new database dump:
```
# First delete the old DB - if there is none, first start the containers
# with "docker compose up" to initialize postgres:
docker compose run db dropdb kantele
docker compose run db createdb kantele
# Now install the new data
# If the containers are down:
docker compose run db psql -U kanteleuser -d kantele -f /pgbackups/file_with_dump.sql
# If you have the containers up:
docker compose exec db psql -U kanteleuser -d kantele -f /pgbackups/file_with_dump.sql
```

## Testing

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ services:
volumes:
- "./src/docker/create_kantele_db.sh:/docker-entrypoint-initdb.d/create_kantele_db.sh"
- "${PG_DATA_PATH:-./false_pg_data}:/var/lib/postgresql/data"
- "${BACKUP_PATH}:/pgbackups"

mq:
extends:
Expand Down

0 comments on commit 730dd22

Please sign in to comment.