datatbase schema provisioning
This commit is contained in:
parent
d991dfdb0c
commit
7ff9b9d648
14
README.md
14
README.md
@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
|
### Prepare the repo
|
||||||
|
|
||||||
|
This is stuff we need to put in makefile but for now...
|
||||||
|
|
||||||
|
File mounts and permisssions need to be set
|
||||||
|
```
|
||||||
|
chmod -R 755 scripts/initdb apps/cic-meta/scripts/initdb
|
||||||
|
````
|
||||||
|
|
||||||
start cluster
|
start cluster
|
||||||
```
|
```
|
||||||
docker-compose up
|
docker-compose up
|
||||||
@ -20,6 +29,7 @@ docker-compose down -v
|
|||||||
rebuild an images
|
rebuild an images
|
||||||
```
|
```
|
||||||
docker-compose up --build <service_name>
|
docker-compose up --build <service_name>
|
||||||
``
|
```
|
||||||
|
|
||||||
|
Deployment variables are writtend to service-configs/.env after everthing is up.
|
||||||
|
|
||||||
Deployment variables are writtend to service-configs/.env after everthing is up.`
|
|
||||||
|
@ -16,7 +16,7 @@ COPY cic-meta/scripts/ scripts/
|
|||||||
RUN alias tsc=node_modules/typescript/bin/tsc
|
RUN alias tsc=node_modules/typescript/bin/tsc
|
||||||
|
|
||||||
COPY cic-meta/.config/ /usr/local/etc/cic-meta/
|
COPY cic-meta/.config/ /usr/local/etc/cic-meta/
|
||||||
COPY cic-meta/scripts/server/initdb/server.postgres.sql /usr/local/share/cic-meta/sql/server.sql
|
# COPY cic-meta/scripts/server/initdb/server.postgres.sql /usr/local/share/cic-meta/sql/server.sql
|
||||||
|
|
||||||
COPY cic-meta/docker/db.sh ./db.sh
|
COPY cic-meta/docker/db.sh ./db.sh
|
||||||
RUN chmod 755 ./db.sh
|
RUN chmod 755 ./db.sh
|
||||||
|
4
apps/cic-meta/scripts/initdb/postgresql.sh
Normal file → Executable file
4
apps/cic-meta/scripts/initdb/postgresql.sh
Normal file → Executable file
@ -1,8 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname cic_meta <<-EOSQL
|
psql -v ON_ERROR_STOP=1 --username grassroots --dbname cic_meta <<-EOSQL
|
||||||
create table if not exists cic_meta.store (
|
create table if not exists store (
|
||||||
id serial primary key not null,
|
id serial primary key not null,
|
||||||
owner_fingerprint text not null,
|
owner_fingerprint text not null,
|
||||||
hash char(64) not null unique,
|
hash char(64) not null unique,
|
||||||
|
0
apps/cic-meta/scripts/initdb/server.postgres.sql
Normal file → Executable file
0
apps/cic-meta/scripts/initdb/server.postgres.sql
Normal file → Executable file
0
apps/cic-meta/scripts/initdb/server.sql
Normal file → Executable file
0
apps/cic-meta/scripts/initdb/server.sql
Normal file → Executable file
0
apps/cic-meta/scripts/initdb/server.sqlite.sql
Normal file → Executable file
0
apps/cic-meta/scripts/initdb/server.sqlite.sql
Normal file → Executable file
@ -44,7 +44,7 @@ services:
|
|||||||
|
|
||||||
# See contents of /initdb/create_db.sql for app user, password and databases
|
# See contents of /initdb/create_db.sql for app user, password and databases
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:10
|
image: postgres:12.5-alpine
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust # for postgres user access w/o password. Obvioulsy not safe but allows easy elevated debugging.
|
POSTGRES_HOST_AUTH_METHOD: trust # for postgres user access w/o password. Obvioulsy not safe but allows easy elevated debugging.
|
||||||
# PGDATA: /tmp/cic/postgres
|
# PGDATA: /tmp/cic/postgres
|
||||||
@ -52,8 +52,7 @@ services:
|
|||||||
- 5432
|
- 5432
|
||||||
volumes:
|
volumes:
|
||||||
- ./scripts/initdb/create_db.sql:/docker-entrypoint-initdb.d/1-create_all_db.sql
|
- ./scripts/initdb/create_db.sql:/docker-entrypoint-initdb.d/1-create_all_db.sql
|
||||||
# - ./apps/cic-meta/scripts/server/initdb/postgresql.sh:/docker-entrypoint-initdb.d/2-init-cic-meta.sh
|
- ./apps/cic-meta/scripts/initdb/postgresql.sh:/docker-entrypoint-initdb.d/2-init-cic-meta.sh
|
||||||
- ./scripts/initdb/postgresql.sh:/docker-entrypoint-initdb.d/2-init-cic-meta.sh
|
|
||||||
- postgres-db:/var/lib/postgresql/data
|
- postgres-db:/var/lib/postgresql/data
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
|
0
scripts/initdb/create_db.sql
Normal file → Executable file
0
scripts/initdb/create_db.sql
Normal file → Executable file
@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname cic_meta <<-EOSQL
|
|
||||||
create table if not exists cic_meta.store (
|
|
||||||
id serial primary key not null,
|
|
||||||
owner_fingerprint text not null,
|
|
||||||
hash char(64) not null unique,
|
|
||||||
content text not null
|
|
||||||
);
|
|
||||||
|
|
||||||
create index if not exists idx_fp on store ((lower(owner_fingerprint)));
|
|
||||||
EOSQL
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user