From 7ff9b9d6489b950975d3db617ddbfcb8b446ddcf Mon Sep 17 00:00:00 2001 From: Blair Vanderlugt Date: Tue, 9 Feb 2021 08:24:47 -0800 Subject: [PATCH] datatbase schema provisioning --- README.md | 14 ++++++++++++-- apps/cic-meta/docker/Dockerfile | 2 +- apps/cic-meta/scripts/initdb/postgresql.sh | 4 ++-- apps/cic-meta/scripts/initdb/server.postgres.sql | 0 apps/cic-meta/scripts/initdb/server.sql | 0 apps/cic-meta/scripts/initdb/server.sqlite.sql | 0 docker-compose.yml | 5 ++--- scripts/initdb/create_db.sql | 0 scripts/initdb/postgresql.sh | 15 --------------- 9 files changed, 17 insertions(+), 23 deletions(-) mode change 100644 => 100755 apps/cic-meta/scripts/initdb/postgresql.sh mode change 100644 => 100755 apps/cic-meta/scripts/initdb/server.postgres.sql mode change 100644 => 100755 apps/cic-meta/scripts/initdb/server.sql mode change 100644 => 100755 apps/cic-meta/scripts/initdb/server.sqlite.sql mode change 100644 => 100755 scripts/initdb/create_db.sql delete mode 100644 scripts/initdb/postgresql.sh diff --git a/README.md b/README.md index d43e6387..9faa6739 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,15 @@ ## 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 ``` docker-compose up @@ -20,6 +29,7 @@ docker-compose down -v rebuild an images ``` docker-compose up --build -`` +``` + +Deployment variables are writtend to service-configs/.env after everthing is up. -Deployment variables are writtend to service-configs/.env after everthing is up.` diff --git a/apps/cic-meta/docker/Dockerfile b/apps/cic-meta/docker/Dockerfile index b4760861..d3440175 100644 --- a/apps/cic-meta/docker/Dockerfile +++ b/apps/cic-meta/docker/Dockerfile @@ -16,7 +16,7 @@ COPY cic-meta/scripts/ scripts/ RUN alias tsc=node_modules/typescript/bin/tsc 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 RUN chmod 755 ./db.sh diff --git a/apps/cic-meta/scripts/initdb/postgresql.sh b/apps/cic-meta/scripts/initdb/postgresql.sh old mode 100644 new mode 100755 index 5e972aaf..75b8ac07 --- a/apps/cic-meta/scripts/initdb/postgresql.sh +++ b/apps/cic-meta/scripts/initdb/postgresql.sh @@ -1,8 +1,8 @@ #!/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 ( +psql -v ON_ERROR_STOP=1 --username grassroots --dbname cic_meta <<-EOSQL + create table if not exists store ( id serial primary key not null, owner_fingerprint text not null, hash char(64) not null unique, diff --git a/apps/cic-meta/scripts/initdb/server.postgres.sql b/apps/cic-meta/scripts/initdb/server.postgres.sql old mode 100644 new mode 100755 diff --git a/apps/cic-meta/scripts/initdb/server.sql b/apps/cic-meta/scripts/initdb/server.sql old mode 100644 new mode 100755 diff --git a/apps/cic-meta/scripts/initdb/server.sqlite.sql b/apps/cic-meta/scripts/initdb/server.sqlite.sql old mode 100644 new mode 100755 diff --git a/docker-compose.yml b/docker-compose.yml index 94b9b7a8..84566564 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: # See contents of /initdb/create_db.sql for app user, password and databases postgres: - image: postgres:10 + image: postgres:12.5-alpine environment: POSTGRES_HOST_AUTH_METHOD: trust # for postgres user access w/o password. Obvioulsy not safe but allows easy elevated debugging. # PGDATA: /tmp/cic/postgres @@ -52,8 +52,7 @@ services: - 5432 volumes: - ./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 - - ./scripts/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 - postgres-db:/var/lib/postgresql/data redis: diff --git a/scripts/initdb/create_db.sql b/scripts/initdb/create_db.sql old mode 100644 new mode 100755 diff --git a/scripts/initdb/postgresql.sh b/scripts/initdb/postgresql.sh deleted file mode 100644 index 5e972aaf..00000000 --- a/scripts/initdb/postgresql.sh +++ /dev/null @@ -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 - -