docker compose and init scripts

This commit is contained in:
Blair Vanderlugt 2021-02-09 07:26:02 -08:00
parent 040fdf6e56
commit d991dfdb0c
7 changed files with 68 additions and 31 deletions

View File

@ -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/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

View File

@ -0,0 +1,15 @@
#!/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

View File

@ -1,4 +1,4 @@
create table if not exists store (
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,

View File

@ -44,15 +44,17 @@ services:
# See contents of /initdb/create_db.sql for app user, password and databases
postgres:
image: postgres:12.5-alpine
image: postgres:10
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
# PGDATA: /tmp/cic/postgres
ports:
- 5432
volumes:
- ./scripts/initdb/create_db.sql:/docker-entrypoint-initdb.d/1-create_all_db.sql # init db scripts will run in order at container start
- postgres-db:/tmp/cic/postgres
- ./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
- postgres-db:/var/lib/postgresql/data
redis:
image: redis:6.0.9-alpine
@ -394,31 +396,36 @@ services:
command: "/root/start_tasker.sh -q cic-notify"
# cic-meta-server:
# image: grassrootseconomics:cic-meta-server
# environment:
# DATABASE_USER: $DATABASE_USER
# DATABASE_HOST: $DATABASE_HOST
# DATABASE_PORT: $DATABASE_PORT
# DATABASE_PASSWORD: $DATABASE_PASSWORD
# DATABASE_NAME: $DATABASE_NAME_CIC_META
# DATABASE_ENGINE: $DATABASE_ENGINE
# DATABASE_DRIVER: $DATABASE_DRIVER
# DATABASE_SCHEMA_SQL_PATH: $DATABASE_SCHEMA_SQL_PATH_CIC_META
# SERVER_PORT: 80
# PGP_PASSPHRASE: $PGP_PASSPHRASE
# PGP_EXPORTS_DIR: $PGP_EXPORTS_DIR
# PGP_PRIVATEKEY_FILE: $PGP_PRIVATEKEY_FILE
# ports:
# - ${HTTP_PORT_CIC_META}:80
# depends_on:
# - postgres
# deploy:
# restart_policy:
# condition: on-failure
# volumes:
# - ${LOCAL_VOLUME_DIR:-/tmp/cic}/pgp:/tmp/cic/pgp
# command: "/root/start_server.sh -vv"
cic-meta-server:
build:
context: apps/
dockerfile: cic-meta/docker/Dockerfile
environment:
DATABASE_NAME: ${DATABASE_NAME:-cic_meta}
DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
DATABASE_USER: ${DATABASE_USER:-grassroots}
DATABASE_HOST: ${DATABASE_HOST:-postgres}
DATABASE_PORT: ${DATABASE_PORT:-5432}
DATABASE_SCHEMA_SQL_PATH: ""
PGP_EXPORTS_DIR: /tmp/src/cic-meta/tests/
PGP_PRIVATEKEY_FILE: privatekeys.asc
PGP_PASSPHRASE: merman
PGP_PUBLICKEY_TRUSTED_FILE: publickeys.asc
PGP_PUBLICKEY_ACTIVE_FILE: publickeys.asc
PGP_PUBLICKEY_ENCRYPT_FILE: publickeys.asc
SERVER_ADDRESS: 0.0.0.0
SERVER_PORT: 7777
ports:
- ${HTTP_PORT_CIC_META:-80}
depends_on:
- postgres
deploy:
restart_policy:
condition: on-failure
volumes:
- ${LOCAL_VOLUME_DIR:-/tmp/cic}/pgp:/tmp/cic/pgp
command: "/root/start_server.sh -vv"
# cic-ussd-server:
# # image: grassrootseconomics:cic-ussd

View File

@ -0,0 +1,15 @@
#!/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