mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Add db container and restore script & instructions
This commit is contained in:
@@ -1 +1,2 @@
|
||||
node_modules
|
||||
data/sqlfiles/*
|
||||
@@ -6,8 +6,22 @@ Rebuild of a fossil database application, old version at https://nowdatabase.luo
|
||||
|
||||
New version not deployed yet.
|
||||
|
||||
### Developer instructions
|
||||
## Developer instructions
|
||||
|
||||
Run `npm install` in all three folders: Project root, frontend, and backend.
|
||||
|
||||
If you have docker compose installed, run `npm run dev` in root to launch docker in development mode. Then, open localhost:5173 in browser.
|
||||
If you have docker compose installed, run `npm run dev` in root to launch docker in development mode. Then, open `localhost:5173` in browser.
|
||||
|
||||
### Restoring db from dump
|
||||
|
||||
Make an empty directory `sqlfiles` inside `data` folder which is in the repository root. Then, put the database dump files `now_test.sql`, `now_log_test.sql` and `now_view.sql` inside it.
|
||||
|
||||
The initialization file (`restore_and_create.sql`) will then restore the database from these files when the container is first run, and also creates a user `'now_test'@'localhost'` with password `mariadb_password` for the database. The root users password will be `admin`.
|
||||
|
||||
**Test that it worked:**
|
||||
|
||||
`docker exec -it nowdb-db mariadb -u now_test -p`. Enter the password `mariadb_password`.
|
||||
|
||||
Select database with `USE now_test;`.
|
||||
|
||||
Execute query: `select loc_name from now_loc where loc_name like "amb%";` which should print 9 rows if everything went right.
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
DROP DATABASE IF EXISTS now_test; CREATE DATABASE now_test CHARACTER SET latin1;
|
||||
DROP DATABASE IF EXISTS now_log_test; CREATE DATABASE now_log_test CHARACTER SET latin1;
|
||||
SET names 'latin1';
|
||||
USE now_test
|
||||
SOURCE /docker-entrypoint-initdb.d/sqlfiles/now_test.sql
|
||||
USE now_log_test
|
||||
SOURCE /docker-entrypoint-initdb.d/sqlfiles/now_log_test.sql
|
||||
USE now_test
|
||||
SOURCE /docker-entrypoint-initdb.d/sqlfiles/now_view.sql
|
||||
|
||||
CREATE USER 'now_test'@'localhost' IDENTIFIED BY 'mariadb_password';
|
||||
GRANT SELECT, INSERT, UPDATE ON `log_test`.* TO 'now_test'@'localhost';
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON `now_test`.* TO 'now_test'@'localhost';
|
||||
@@ -17,3 +17,18 @@ services:
|
||||
- 4000:4000
|
||||
command: >
|
||||
sh -c "cd /usr/src/app && npm ci && npm run dev"
|
||||
now-db:
|
||||
container_name: nowdb-db
|
||||
image: mariadb
|
||||
environment:
|
||||
MARIADB_ROOT_PASSWORD: admin
|
||||
MARIADB_HOST: localhost
|
||||
MARIADB_DATABASE: now_test
|
||||
MARIADB_LOG_DATABASE: now_log_test.log
|
||||
MARIADB_USER: now_test
|
||||
MARIADB_PASSWORD: mariadb_password
|
||||
volumes:
|
||||
- ./data/:/docker-entrypoint-initdb.d
|
||||
volumes:
|
||||
nowdb-db:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user