Skip to content

Commit

Permalink
Adding workflow to save as Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
pgoslatara committed Jun 29, 2024
1 parent 4770a87 commit ef30a01
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 4 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/cd_pipeline.yml
Original file line number Diff line number Diff line change
@@ -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 }}
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

0 comments on commit ef30a01

Please sign in to comment.