From a3261f2f0e1a285697f18a27559edb8619602ac9 Mon Sep 17 00:00:00 2001 From: Blair Vanderlugt Date: Fri, 30 Apr 2021 08:33:33 +0000 Subject: [PATCH] fixed cic meta migration and removed pg schema stuff during init --- apps/cic-cache/docker/Dockerfile | 4 ---- apps/cic-eth/docker/Dockerfile | 4 ---- apps/cic-meta/.config/pgp.ini | 2 +- apps/cic-meta/docker/Dockerfile | 19 ++++++++++++------- apps/cic-meta/docker/db.sh | 2 +- apps/cic-meta/docker/start_server.sh | 4 +++- apps/cic-meta/package.json | 3 ++- apps/cic-meta/scripts/initdb/postgresql.sh | 15 --------------- apps/contract-migration/docker/Dockerfile | 13 ++----------- docker-compose.yml | 3 +-- 10 files changed, 22 insertions(+), 47 deletions(-) delete mode 100755 apps/cic-meta/scripts/initdb/postgresql.sh diff --git a/apps/cic-cache/docker/Dockerfile b/apps/cic-cache/docker/Dockerfile index ed01fd5..8330402 100644 --- a/apps/cic-cache/docker/Dockerfile +++ b/apps/cic-cache/docker/Dockerfile @@ -43,10 +43,6 @@ COPY cic-cache/config/ /usr/local/etc/cic-cache/ RUN git clone https://github.com/vishnubob/wait-for-it.git /usr/local/bin/wait-for-it/ COPY cic-cache/cic_cache/db/migrations/ /usr/local/share/cic-cache/alembic/ -RUN git clone https://gitlab.com/grassrootseconomics/cic-contracts.git && \ - mkdir -p /usr/local/share/cic/solidity && \ - cp -R cic-contracts/abis /usr/local/share/cic/solidity/abi - COPY cic-cache/docker/start_tracker.sh ./start_tracker.sh COPY cic-cache/docker/db.sh ./db.sh RUN chmod 755 ./*.sh diff --git a/apps/cic-eth/docker/Dockerfile b/apps/cic-eth/docker/Dockerfile index 00f3903..27d8e5c 100644 --- a/apps/cic-eth/docker/Dockerfile +++ b/apps/cic-eth/docker/Dockerfile @@ -50,8 +50,4 @@ COPY cic-eth/config/ /usr/local/etc/cic-eth/ COPY cic-eth/cic_eth/db/migrations/ /usr/local/share/cic-eth/alembic/ COPY cic-eth/crypto_dev_signer_config/ /usr/local/etc/crypto-dev-signer/ -RUN git clone https://gitlab.com/grassrootseconomics/cic-contracts.git && \ - mkdir -p /usr/local/share/cic/solidity && \ - cp -R cic-contracts/abis /usr/local/share/cic/solidity/abi - COPY util/liveness/health.sh /usr/local/bin/health.sh diff --git a/apps/cic-meta/.config/pgp.ini b/apps/cic-meta/.config/pgp.ini index 8c8826c..6092598 100644 --- a/apps/cic-meta/.config/pgp.ini +++ b/apps/cic-meta/.config/pgp.ini @@ -1,5 +1,5 @@ [pgp] -exports_dir = pgp +exports_dir = /root/pgp privatekey_file = privatekeys.asc passphrase = merman publickey_trusted_file = publickeys.asc diff --git a/apps/cic-meta/docker/Dockerfile b/apps/cic-meta/docker/Dockerfile index f81e672..ebfa884 100644 --- a/apps/cic-meta/docker/Dockerfile +++ b/apps/cic-meta/docker/Dockerfile @@ -2,26 +2,31 @@ FROM node:15.3.0-alpine3.10 WORKDIR /tmp/src/cic-meta +RUN apk add --no-cache postgresql + COPY cic-meta/package.json \ ./ COPY cic-meta/src/ src/ COPY cic-meta/tests/ tests/ COPY cic-meta/scripts/ scripts/ -#COPY docker/*.sh /root/ - -RUN alias tsc=node_modules/typescript/bin/tsc RUN npm install +# see exports_dir gpg.ini +COPY cic-meta/tests/*.asc /root/pgp/ +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/docker/db.sh ./db.sh RUN chmod 755 ./db.sh -RUN alias ts-node=/tmp/src/cic-meta/node_modules/ts-node/dist/bin.js -ENTRYPOINT [ "./node_modules/ts-node/dist/bin.js", "./scripts/server/server.ts" ] +#RUN alias ts-node=/tmp/src/cic-meta/node_modules/ts-node/dist/bin.js +#ENTRYPOINT [ "./node_modules/ts-node/dist/bin.js", "./scripts/server/server.ts" ] -# COPY cic-meta/docker/start_server.sh ./start_server.sh -# RUN chmod 755 ./start_server.sh +COPY cic-meta/docker/start_server.sh ./start_server.sh +RUN chmod 755 ./start_server.sh +ENTRYPOINT ["sh", "./start_server.sh"] diff --git a/apps/cic-meta/docker/db.sh b/apps/cic-meta/docker/db.sh index 78b9735..8b222fd 100644 --- a/apps/cic-meta/docker/db.sh +++ b/apps/cic-meta/docker/db.sh @@ -1,3 +1,3 @@ #!/bin/bash -PGPASSWORD=$DATABASE_PASSWORD psql -U $DATABASE_USER -h $DATABASE_HOST -p $DATABASE_PORT -d $DATABASE_NAME /usr/local/share/cic-meta/sql/server.sql +PGPASSWORD=$DATABASE_PASSWORD psql -U $DATABASE_USER -h $DATABASE_HOST -p $DATABASE_PORT -d $DATABASE_NAME -f $SCHEMA_SQL_PATH diff --git a/apps/cic-meta/docker/start_server.sh b/apps/cic-meta/docker/start_server.sh index ff11d35..5c3ced7 100644 --- a/apps/cic-meta/docker/start_server.sh +++ b/apps/cic-meta/docker/start_server.sh @@ -1,3 +1,5 @@ sh ./db.sh -/usr/local/bin/node /usr/local/bin/cic-meta-server $@ +# /usr/local/bin/node /usr/local/bin/cic-meta-server $@ +# ./node_modules/ts-node/dist/bin.js", "./scripts/server/server.ts $@ +npm run start "$@" diff --git a/apps/cic-meta/package.json b/apps/cic-meta/package.json index fd3bd05..a04d01d 100644 --- a/apps/cic-meta/package.json +++ b/apps/cic-meta/package.json @@ -10,7 +10,8 @@ "build-server": "tsc -d --outDir dist-server scripts/server/*.ts", "pack": "node_modules/typescript/bin/tsc -d --outDir dist && webpack", "clean": "rm -rf dist", - "prepare": "npm run build && npm run build-server" + "prepare": "npm run build && npm run build-server", + "start": "./node_modules/ts-node/dist/bin.js ./scripts/server/server.ts" }, "dependencies": { "@ethereumjs/tx": "^3.0.0-beta.1", diff --git a/apps/cic-meta/scripts/initdb/postgresql.sh b/apps/cic-meta/scripts/initdb/postgresql.sh deleted file mode 100755 index 75b8ac0..0000000 --- a/apps/cic-meta/scripts/initdb/postgresql.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -set -e - -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, - content text not null - ); - - create index if not exists idx_fp on store ((lower(owner_fingerprint))); -EOSQL - - diff --git a/apps/contract-migration/docker/Dockerfile b/apps/contract-migration/docker/Dockerfile index 7f9f2b8..523703a 100644 --- a/apps/contract-migration/docker/Dockerfile +++ b/apps/contract-migration/docker/Dockerfile @@ -31,15 +31,6 @@ RUN echo Install confini schema files && \ git checkout $cic_config_commit && \ cp -v *.ini $CONFINI_DIR -ARG cic_contracts_commit=698ef3a30fde8d7f2c498f1208fb0ff45d665501 -ARG cic_contracts_url=https://gitlab.com/grassrootseconomics/cic-contracts.git/ -RUN echo Install ABI collection for solidity interfaces used across all components && \ - git clone --depth 1 $cic_contracts_url cic-contracts && \ - cd cic-contracts && \ - git fetch --depth 1 origin $cic_contracts_commit && \ - git checkout $cic_contracts_commit && \ - make install - # Install nvm with node and npm # https://stackoverflow.com/questions/25899912/how-to-install-nvm-in-docker ENV NVM_DIR /root/.nvm @@ -64,9 +55,9 @@ ARG pip_extra_index_url=https://pip.grassrootseconomics.net:8433 ARG cic_base_version=0.1.2a79 ARG cic_eth_version=0.11.0b8+build.c2286e5c ARG sarafu_faucet_version=0.0.2a28 -ARG sarafu_token_version==0.0.1a6 +ARG sarafu_token_version=0.0.1a6 ARG cic_contracts_version=0.0.2a2 -RUN pip install --user --extra-index-url $pip_extra_index_url cic-base[full_graph]==$cic_base_version \ +RUN pip install --user --index-url https://pypi.org/simple --extra-index-url $pip_extra_index_url cic-base[full_graph]==$cic_base_version \ cic-eth==$cic_eth_version \ cic-contracts==$cic_contracts_version \ sarafu-faucet==$sarafu_faucet_version \ diff --git a/docker-compose.yml b/docker-compose.yml index a3abb77..dbb61f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,8 +53,6 @@ services: command: [ "-c", "max_connections=200" ] volumes: - ./scripts/initdb/create_db.sql:/docker-entrypoint-initdb.d/1-create_all_db.sql - - ./apps/cic-meta/scripts/initdb/postgresql.sh:/docker-entrypoint-initdb.d/2-init-cic-meta.sh - - ./apps/cic-cache/db/psycopg2/db.sql:/docker-entrypoint-initdb.d/3-init-cic-meta.sql - postgres-db:/var/lib/postgresql/data redis: @@ -477,6 +475,7 @@ services: PGP_PUBLICKEY_TRUSTED_FILE: publickeys.asc PGP_PUBLICKEY_ACTIVE_FILE: publickeys.asc PGP_PUBLICKEY_ENCRYPT_FILE: publickeys.asc + SCHEMA_SQL_PATH: scripts/initdb/server.postgres.sql ports: - ${HTTP_PORT_CIC_META:-63380}:8000 depends_on: