-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
105 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,7 @@ POSTGRES_PASSWORD=dbtmetabase1 | |
POSTGRES_DB=dbtmetabase | ||
POSTGRES_SCHEMA=public | ||
POSTGRES_PORT=5432 | ||
MB_SETUP_TOKEN=2ffe1bc9-4bc5-4184-a10d-731517d8e4a3 | ||
MB_USER=[email protected] | ||
MB_PASSWORD=dbtmetabase1 | ||
MB_PORT=3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
FROM python:3.11-slim-bullseye | ||
|
||
RUN python3 -m pip install dbt-postgres | ||
|
||
WORKDIR /app | ||
|
||
COPY requirements.txt ./ | ||
|
||
RUN python3 -m pip install -r requirements.txt | ||
|
||
COPY entrypoint.py ./ | ||
COPY dbt_project.yml ./ | ||
COPY models/ ./models/ | ||
COPY profiles.yml ./ | ||
|
||
CMD dbt run --profiles-dir . | ||
ENTRYPOINT ["python3", "entrypoint.py"] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env python | ||
|
||
import requests | ||
from molot import target, envarg, envarg_int, evaluate, shell | ||
|
||
POSTGRES_HOST = envarg("POSTGRES_HOST") | ||
POSTGRES_PORT = envarg_int("POSTGRES_PORT") | ||
POSTGRES_DB = envarg("POSTGRES_DB") | ||
POSTGRES_USER = envarg("POSTGRES_USER") | ||
POSTGRES_PASSWORD = envarg("POSTGRES_PASSWORD") | ||
MB_HOST = envarg("MB_HOST") | ||
MB_PORT = envarg_int("MB_PORT") | ||
MB_SETUP_TOKEN = envarg("MB_SETUP_TOKEN") | ||
MB_USER = envarg("MB_USER") | ||
MB_PASSWORD = envarg("MB_PASSWORD") | ||
MB_NAME = envarg("MB_NAME", "dbtmetabase") | ||
|
||
|
||
@target(description="set up Metabase user and database") | ||
def setup_metabase(): | ||
requests.post( | ||
f"http://{MB_HOST}:{MB_PORT}/api/setup", | ||
json={ | ||
"token": MB_SETUP_TOKEN, | ||
"user": { | ||
"site_name": MB_NAME, | ||
"first_name": MB_NAME, | ||
"last_name": None, | ||
"email": MB_USER, | ||
"password_confirm": MB_PASSWORD, | ||
"password": MB_PASSWORD, | ||
}, | ||
"database": { | ||
"engine": "postgres", | ||
"name": POSTGRES_DB, | ||
"details": { | ||
"host": POSTGRES_HOST, | ||
"port": POSTGRES_PORT, | ||
"dbname": POSTGRES_DB, | ||
"user": POSTGRES_USER, | ||
"password": POSTGRES_PASSWORD, | ||
"schema-filters-type": "all", | ||
"ssl": False, | ||
"tunnel-enabled": False, | ||
"advanced-options": False, | ||
}, | ||
"is_on_demand": False, | ||
"is_full_sync": True, | ||
"is_sample": False, | ||
"cache_ttl": None, | ||
"refingerprint": False, | ||
"auto_run_queries": True, | ||
"schedules": {}, | ||
}, | ||
"prefs": { | ||
"site_name": MB_NAME, | ||
"site_locale": "en", | ||
"allow_tracking": "false", | ||
}, | ||
}, | ||
timeout=10, | ||
).raise_for_status() | ||
|
||
|
||
@target(description="run dbt project") | ||
def run_dbt(): | ||
shell("dbt run --profiles-dir .") | ||
|
||
|
||
@target(description="initial setup", depends=["setup_metabase", "run_dbt"]) | ||
def init(): | ||
pass | ||
|
||
|
||
evaluate() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
molot | ||
requests | ||
dbt-postgres |