Giter Club home page Giter Club logo

docker-dbt's Introduction

DBT docker image

a dbt docker image with an entrypoint that :

  1. clone the ${GIT_REPO} with the ${GIT_TOKEN}

  2. eval the profiles.yaml to replace the ${...} by given value

  3. run the user CMD

1) Use locally

1.1) create .env file with a github token (for local test)

~/REPO/raphaelauv/dbt-docker$ cat <<EOT >> .env
GITHUB_TOKEN=REPLACE_ME_WITH_YOUR_GITHUB_TOKEN
EOT

1.2) Build and run the container

~/REPO/raphaelauv/dbt-docker$ docker-compose build
~/REPO/raphaelauv/dbt-docker$ docker-compose up

2) Use with Airflow ( Kubernetes )

"""
# Dag goal ...
"""
from pendulum import today
from airflow import DAG
from airflow.kubernetes.secret import Secret
from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import KubernetesPodOperator


dag = DAG("dbt_test",
          schedule_interval="@daily",
          start_date=today("UTC").add(days=-1),
          tags=['dbt'],
          doc_md=__doc__,
          catchup=False,
          max_active_runs=1
          )

secret_service_account = Secret(
    deploy_type="volume",
    deploy_target="/var/secrets/google",
    secret="MY_SECRET",
    key="service-account.json")

secret_git_token = Secret(
    deploy_type='env',
    deploy_target='GIT_TOKEN',
    secret="REPO-github-token",
    key='git_token')

with dag:
    KubernetesPodOperator(
        task_id="dbt_test",
        name="airflow-dags.dbt",
        namespace="default",
        arguments=["dbt", "run", "--profiles-dir", "."],
        env_vars={  # noqa
            "GOOGLE_APPLICATION_CREDENTIALS": "/var/secrets/google/service-account.json",
            "GIT_REPO": "user_name/MY_REPO.git",
            "PROJECT": "my-gcp-project-name"
        },
        secrets=[secret_service_account, secret_git_token],
        is_delete_operator_pod=True,
        deferrable=True,
        image="dbt:0.1")

docker-dbt's People

Contributors

raphaelauv avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.