diff --git a/.github/workflows/cd_pipeline.yml b/.github/workflows/cd_pipeline.yml new file mode 100644 index 00000000..d7bde3ed --- /dev/null +++ b/.github/workflows/cd_pipeline.yml @@ -0,0 +1,55 @@ +--- +name: CD pipeline + +on: + push: + branches: + - main + +jobs: + cd_pipeline: + name: Build Docker image + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + dbt-bouncer + tags: | + type=ref,event=branch + type=raw,value=${{ github.sha }} + type=raw,value=test + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: https://ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Determine python version + id: python-version + run: | + export PYTHON_VERSION=$(cat .python-version) + echo "PYTHON_VERSION: $PYTHON_VERSION" + echo "PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_OUTPUT + + - name: Build image + uses: docker/build-push-action@v5 + with: + build-args: PYTHON_VERSION=${{ steps.python-version.outputs.PYTHON_VERSION }} + cache-from: type=gha + cache-to: type=gha,mode=max + context: . + load: false + push: false + tags: ${{ steps.meta.outputs.tags }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..15ad5a18 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +ARG PYTHON_VERSION +FROM python:${PYTHON_VERSION}-slim + +# https://python-poetry.org/docs#ci-recommendations +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + POETRY_VERSION=1.7.1 \ + POETRY_HOME=/opt/poetry \ + POETRY_VENV=/opt/poetry-venv + +# Creating a virtual environment just for poetry and install it with pip +RUN python3 -m venv $POETRY_VENV \ + && $POETRY_VENV/bin/pip install --no-cache-dir -U pip setuptools \ + && $POETRY_VENV/bin/pip install --no-cache-dir poetry==${POETRY_VERSION} + +# Add Poetry to PATH +ENV PATH="${PATH}:${POETRY_VENV}/bin" + +WORKDIR /app + +# Copy Dependencies +COPY poetry.lock pyproject.toml README.md ./ +COPY dbt_bouncer ./dbt_bouncer + +# Install Dependencies +RUN poetry install --no-cache --no-interaction --without dev \ + && rm -rf ~/.cache/pypoetry/artifacts + +CMD ["/bin/bash", "-c", "echo 'Expecting commands to be passed in.' && exit 1"] diff --git a/poetry.lock b/poetry.lock index bcd0cba9..5c41c406 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "agate" @@ -1647,4 +1647,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = ">=3.8,<3.13" -content-hash = "38c055715598d8baa684941fc531dca0b6dde5d075555e451a76177fdbffd72a" +content-hash = "6383999515b178a8d1a3db8f688c1c0a0cc9df835b8ff177f24a0e24fc3849dd" diff --git a/pyproject.toml b/pyproject.toml index bab857e7..8788b416 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ version = "0.0.0" python = ">=3.8,<3.13" click = "*" -[tool.poetry.dev-dependencies] +[tool.poetry.group.dev.dependencies] dbt-core="*" dbt-duckdb="*" pre-commit = "^3" @@ -59,5 +59,5 @@ dbt_bouncer = "dbt_bouncer.main:cli" [tool.poetry_bumpversion.file."./dbt_bouncer/version.py"] [build-system] -requires = ["poetry-core>=1.0.0"] +requires = ["poetry-core>=1.6.0"] build-backend = "poetry.core.masonry.api"