Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#182): add local path #188

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dbt/dbt-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def get_package():
"revision": init_package.fragment
}]})

if os.getenv("DBT_LOCAL_PATH"):
package_json = json.dumps({"packages": [{
"local": '/dbt/package/'
}]})

with open("/dbt/packages.yml", "w") as f:
f.write(package_json)

Expand Down
41 changes: 41 additions & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: ${COMPOSE_PROJECT_NAME:-cht-sync}
services:
couch2pg:
build: ./couch2pg/
extra_hosts:
- "host.docker.internal:host-gateway"
logging:
driver: "json-file"
options:
max-size: "512m"
environment:
- COUCHDB_USER=${COUCHDB_USER}
- COUCHDB_PASSWORD=${COUCHDB_PASSWORD}
- COUCHDB_HOST=${COUCHDB_HOST}
- COUCHDB_DBS=${COUCHDB_DBS}
- COUCHDB_PORT=${COUCHDB_PORT}
- COUCHDB_SECURE=${COUCHDB_SECURE:-true}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_HOST=${POSTGRES_HOST}
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_PORT=5432
- POSTGRES_SCHEMA=${POSTGRES_SCHEMA}
- POSTGRES_TABLE=${POSTGRES_TABLE}
restart: always

dbt:
build: ./dbt/
working_dir: /dbt/
volumes:
- "${DBT_LOCAL_PATH}:/dbt/package/"
environment:
- POSTGRES_HOST=${POSTGRES_HOST}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_TABLE=${POSTGRES_TABLE}
- POSTGRES_SCHEMA=${POSTGRES_SCHEMA}
- ROOT_POSTGRES_SCHEMA=${POSTGRES_SCHEMA}
- DATAEMON_INTERVAL=${DATAEMON_INTERVAL}
- DBT_LOCAL_PATH=${DBT_LOCAL_PATH}
3 changes: 3 additions & 0 deletions env.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ POSTGRES_PORT=5432
CHT_PIPELINE_BRANCH_URL="https://github.com/medic/cht-pipeline.git#main"
DATAEMON_INTERVAL=5

# if running locally, path to pipeline
DBT_LOCAL_PATH="/path/to/cht-pipeline/"

# couchdb
COUCHDB_USER=medic
COUCHDB_PASSWORD=password
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"main": "",
"scripts": {
"postinstall": "cd couch2pg && npm ci",
"test:e2e": "npm run test:e2e-data && npm run test:e2e-containers && mocha tests/**/*.spec.js --timeout 50000; npm run test:e2e-stop-containers ",
"test:e2e": "npm run test:e2e-data && npm run test:e2e-containers && mocha tests/**/*.spec.js --timeout 50000 && npm run test:e2e-stop-containers ",
"lint": "eslint --color --cache .",
"test:e2e-stop-containers": "docker compose --env-file ./tests/.e2e-env -f docker-compose.yml -f docker-compose.couchdb.yml -f docker-compose.postgres.yml down -v",
"test:e2e-containers": "docker compose --env-file ./tests/.e2e-env -f docker-compose.yml -f docker-compose.couchdb.yml -f docker-compose.postgres.yml -f tests/dbt/docker-compose.yml up -d --build --force-recreate",
"test:e2e-stop-containers": "docker compose --env-file ./tests/.e2e-env -f docker-compose.local.yml -f docker-compose.couchdb.yml -f docker-compose.postgres.yml down -v",
"test:e2e-containers": "docker compose --env-file ./tests/.e2e-env -f docker-compose.local.yml -f docker-compose.couchdb.yml -f docker-compose.postgres.yml up -d --build --force-recreate",
"test:e2e-data": "cd tests/data && rm -rf ./json_docs && cht csv-to-docs",
"test": "cd couch2pg && npm run test"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/.e2e-env
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DBT_POSTGRES_USER="postgres"
DBT_POSTGRES_PASSWORD="postgres"
DBT_POSTGRES_SCHEMA="dbt"
DBT_POSTGRES_HOST="postgres"
DBT_PACKAGE_TARBALL_URL="http://dbt-package/dbt/package.tar.gz"
DBT_LOCAL_PATH="./tests/dbt/package"
DATAEMON_INTERVAL=0
COUCHDB_USER="medic"
COUCHDB_PASSWORD="password"
Expand Down
15 changes: 0 additions & 15 deletions tests/dbt/Dockerfile

This file was deleted.

5 changes: 0 additions & 5 deletions tests/dbt/docker-compose.yml

This file was deleted.

21 changes: 0 additions & 21 deletions tests/dbt/nginx.conf

This file was deleted.

Loading