Skip to content

Commit

Permalink
Makes it possible to initialize a cloud deployment using docker-compo…
Browse files Browse the repository at this point in the history
…se (#85)

* Makes it possible to initialize a cloud deployment using docker-compose

* Fix shellcheck issues

* Reuse HASURA_GRAPHQL_DATABASE_URL

* Fix cmd line optional args building
  • Loading branch information
ypc-faros committed Mar 30, 2022
1 parent 8891681 commit 3a8e786
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,16 @@ AIRBYTE_URL=http://airbyte-webapp:80
############################## Hasura #########################################
HASURA_DB_NAME=hasura
HASURA_PORT=8080
HASURA_GRAPHQL_ADMIN_SECRET=admin
HASURA_URL=http://hasura:8080
HASURA_VERSION=v2.1.1

############################## Metabase #######################################
METABASE_DB_NAME=metabase
METABASE_PORT=3000
METABASE_USER=[email protected]
METABASE_PASSWORD=admin
METABASE_URL=http://metabase:3000

############################## n8n ############################################
N8N_DB_NAME=n8n
Expand Down
12 changes: 8 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,18 @@ services:
- ${DATABASE_PORT?}:5432
restart: unless-stopped
faros-init:
profiles: ["default"]
profiles: ["default", "faros-init"]
image: farosai/faros-ce-init:latest
restart: on-failure
environment:
AIRBYTE_API_CALLS_CONCURRENCY: ${AIRBYTE_API_CALLS_CONCURRENCY:-}
AIRBYTE_FORCE_SETUP: ${FAROS_AIRBYTE_FORCE_SETUP:-false}
AIRBYTE_URL: ${AIRBYTE_URL}
AIRBYTE_URL: ${AIRBYTE_URL?}
FAROS_EMAIL: ${FAROS_EMAIL}
HASURA_URL: http://hasura:8080
HASURA_URL: ${HASURA_URL?}
LOG_LEVEL: ${FAROS_INIT_LOG_LEVEL:-info}
METABASE_PASSWORD: ${METABASE_PASSWORD?}
METABASE_URL: http://metabase:3000
METABASE_URL: ${METABASE_URL?}
METABASE_USER: ${METABASE_USER?}
FAROS_DB_NAME: ${FAROS_DB_NAME?}
FAROS_DB_HOST: ${FAROS_DB_HOST?}
Expand All @@ -67,7 +68,9 @@ services:
FAROS_CONFIG_DB_PORT: ${FAROS_CONFIG_DB_PORT?}
FAROS_CONFIG_DB_USER: ${FAROS_CONFIG_DB_USER?}
FAROS_CONFIG_DB_PASSWORD: ${FAROS_CONFIG_DB_PASSWORD?}
HASURA_GRAPHQL_DATABASE_URL: ${HASURA_GRAPHQL_DATABASE_URL:-}
HASURA_DB_NAME: ${HASURA_DB_NAME?}
HASURA_GRAPHQL_ADMIN_SECRET: ${HASURA_GRAPHQL_ADMIN_SECRET?}
METABASE_DB_NAME: ${METABASE_DB_NAME?}
N8N_DB_NAME: ${N8N_DB_NAME?}
hasura:
Expand All @@ -80,6 +83,7 @@ services:
- faros-init
restart: unless-stopped
environment:
HASURA_GRAPHQL_ADMIN_SECRET: ${HASURA_GRAPHQL_ADMIN_SECRET?}
HASURA_GRAPHQL_DATABASE_URL: postgres://${FAROS_DB_USER?}:${FAROS_DB_PASSWORD?}@${FAROS_DB_HOST?}:${FAROS_DB_PORT?}/${FAROS_DB_NAME?}
HASURA_GRAPHQL_DEV_MODE: "false"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup
Expand Down
25 changes: 20 additions & 5 deletions init/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
#!/bin/sh
#!/bin/bash

airbyte_url=$AIRBYTE_URL
airbyte_force_setup=$AIRBYTE_FORCE_SETUP
airbyte_api_calls_concurrency=$AIRBYTE_API_CALLS_CONCURRENCY
hasura_admin_secret=$HASURA_GRAPHQL_ADMIN_SECRET
hasura_database_url=$HASURA_GRAPHQL_DATABASE_URL
hasura_url=$HASURA_URL
metabase_url=$METABASE_URL
db_host=$FAROS_DB_HOST
db_port=$FAROS_DB_PORT

./wait-for/wait-for.sh "$db_host":"$db_port" -- ./db-init.sh

airbyte_optional_args=()

if [ "${airbyte_force_setup}" = "true" ]; then
./wait-for/wait-for.sh "$airbyte_url"/api/v1/health -t 60 -- node ../lib/airbyte/init --airbyte-url "$airbyte_url" --force-setup
else
./wait-for/wait-for.sh "$airbyte_url"/api/v1/health -t 60 -- node ../lib/airbyte/init --airbyte-url "$airbyte_url"
airbyte_optional_args=(--force-setup)
fi

if [ -n "${airbyte_api_calls_concurrency}" ]; then
airbyte_optional_args=("${airbyte_optional_args[@]}" --airbyte-api-calls-concurrency "${airbyte_api_calls_concurrency}")
fi

./wait-for/wait-for.sh "$airbyte_url"/api/v1/health -t 60 -- node ../lib/airbyte/init --airbyte-url "$airbyte_url" "${airbyte_optional_args[@]}"

hasura_optional_args=()

if [ -n "${hasura_database_url}" ]; then
hasura_optional_args=("${hasura_optional_args[@]}" --database-url "${hasura_database_url}")
fi

./wait-for/wait-for.sh "$hasura_url"/healthz -t 60 -- node ../lib/hasura/init --hasura-url "$hasura_url"
./wait-for/wait-for.sh "$hasura_url"/healthz -t 60 -- node ../lib/hasura/init --hasura-url "$hasura_url" --admin-secret "$hasura_admin_secret" "${hasura_optional_args[@]}"
./wait-for/wait-for.sh "$metabase_url"/api/health -t 60 -- ./metabase-init.sh

node ../lib/banner

0 comments on commit 3a8e786

Please sign in to comment.