split running migrations into separate compose step; docker-compose files for different processes

This commit is contained in:
Ian Norden
2020-03-18 12:21:29 -05:00
parent 6ded3a6c85
commit 1d4b37aca9
9 changed files with 286 additions and 67 deletions
+59
View File
@@ -0,0 +1,59 @@
version: '3.2'
services:
db:
restart: always
image: postgres:10.12-alpine
environment:
POSTGRES_USER: "vdbm"
POSTGRES_DB: "vulcanize_public"
POSTGRES_PASSWORD: "password"
volumes:
- vulcanizedb_db_data:/var/lib/postgresql/data
expose:
- "5432"
ports:
- "127.0.0.1:8079:5432"
migrations:
restart: on-failure
depends_on:
- db
build:
context: ./../../
cache_from:
- alpine:latest
dockerfile: ./dockerfiles/migrations/Dockerfile
environment:
DATABASE_NAME: "vulcanize_public"
DATABASE_HOSTNAME: "db"
DATABASE_PORT: 5432
DATABASE_USER: "vdbm"
DATABASE_PASSWORD: "password"
resync:
depends_on:
- db
- migrations
build:
context: ./../../
cache_from:
- alpine:latest
- golang:1.12.4
dockerfile: ./dockerfiles/super_node/Dockerfile
args:
USER: "vdbm"
CONFIG_FILE: ./environments/superNodeBTC.toml
environment:
IPFS_INIT: "true"
DATABASE_NAME: "vulcanize_public"
DATABASE_HOSTNAME: "db"
DATABASE_PORT: 5432
DATABASE_USER: "vdbm"
DATABASE_PASSWORD: "password"
ports:
- "127.0.0.1:8082:8082"
- "127.0.0.1:8083:8083"
volumes:
vulcanizedb_db_data:
+8 -23
View File
@@ -21,28 +21,13 @@ export IPFS_PGDATABASE=$DATABASE_NAME
export IPFS_PGPORT=$DATABASE_PORT
export IPFS_PGPASSWORD=$DATABASE_PASSWORD
# Construct the connection string for postgres
VDB_PG_CONNECT=postgresql://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOSTNAME:$DATABASE_PORT/$DATABASE_NAME?sslmode=disable
# Run the DB migrations
echo "Connecting with: $VDB_PG_CONNECT"
echo "Running database migrations"
./goose -dir migrations/vulcanizedb postgres "$VDB_PG_CONNECT" up
# If the db migrations ran without err
if [[ $? -eq 0 ]]; then
# and IPFS_INIT is true
if [[ "$IPFS_INIT" = true ]] ; then
# initialize PG-IPFS
echo "Initializing Postgres-IPFS profile"
./ipfs init --profile=postgresds
else
echo "IPFS profile already initialized, skipping initialization"
fi
# If IPFS_INIT is true
if [[ "$IPFS_INIT" = true ]] ; then
# initialize PG-IPFS
echo "Initializing Postgres-IPFS profile"
./ipfs init --profile=postgresds
else
echo "Could not run migrations. Are the database details correct?"
exit
echo "IPFS profile already initialized, skipping initialization"
fi
# If IPFS initialization was successful
@@ -51,7 +36,7 @@ if [[ $? -eq 0 ]]; then
./vulcanizedb resync --config=config.toml 2>&1 | tee -a vulcanizedb.log &
else
echo "Could not initialize IPFS."
exit
exit 1
fi
# If Vulcanizedb startup was successful
@@ -59,7 +44,7 @@ if [ $? -eq 0 ]; then
echo "Resync successfully booted"
else
echo "Could not start vulcanizedb resync process. Is the config file correct?"
exit
exit 1
fi
tail -f vulcanizedb.log