Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 3237173

Browse files
mikealfareemmyoop
andauthored
Add docker release to the full release process for final releases (#1170)
* add docker release to release pipeline * add docker to dependabot * update Dockerfile to match new release pipeline * update release pipeline to match new release pipeline * update readme to match the new container * update make recipe * update dev docker image * add permissions for nightly release * don’t release docker when testing, allow to release only docker * Update docker/Dockerfile * remove unused test script --------- Co-authored-by: Emily Rockman <[email protected]>
1 parent dd300f9 commit 3237173

File tree

9 files changed

+186
-94
lines changed

9 files changed

+186
-94
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ updates:
1010
schedule:
1111
interval: "weekly"
1212
rebase-strategy: "disabled"
13+
- package-ecosystem: "docker"
14+
directory: "/docker"
15+
schedule:
16+
interval: "weekly"
17+
rebase-strategy: "disabled"

.github/workflows/nightly-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ on:
2020

2121
permissions:
2222
contents: write # this is the permission that allows creating a new release
23+
packages: write # allows creating a Docker release as a GitHub package on GHCR
2324

2425
defaults:
2526
run:

.github/workflows/release.yml

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
#
1414
# **when?**
1515
# This workflow can be run manually on demand or can be called by other workflows
16-
name: Release to GitHub and PyPI
16+
name: "Release to GitHub, PyPI, and Docker"
17+
run-name: "Release ${{ inputs.version_number }} to GitHub, PyPI, and Docker"
1718

1819
on:
1920
workflow_dispatch:
@@ -60,6 +61,11 @@ on:
6061
type: boolean
6162
default: false
6263
required: false
64+
only_docker:
65+
description: "Only release Docker image, skip GitHub & PyPI"
66+
type: boolean
67+
default: false
68+
required: false
6369
workflow_call:
6470
inputs:
6571
sha:
@@ -128,30 +134,25 @@ jobs:
128134
echo Package test command: ${{ inputs.package_test_command }}
129135
echo Test run: ${{ inputs.test_run }}
130136
echo Nightly release: ${{ inputs.nightly_release }}
137+
echo Only Docker: ${{ inputs.only_docker }}
131138
132139
bump-version-generate-changelog:
133140
name: Bump package version, Generate changelog
134-
135141
uses: dbt-labs/dbt-release/.github/workflows/release-prep.yml@main
136-
137142
with:
138143
sha: ${{ inputs.sha }}
139144
version_number: ${{ inputs.version_number }}
140145
target_branch: ${{ inputs.target_branch }}
141146
env_setup_script_path: ${{ inputs.env_setup_script_path }}
142147
test_run: ${{ inputs.test_run }}
143148
nightly_release: ${{ inputs.nightly_release }}
144-
145149
secrets: inherit
146150

147151
log-outputs-bump-version-generate-changelog:
148152
name: "[Log output] Bump package version, Generate changelog"
149-
if: ${{ !failure() && !cancelled() }}
150-
153+
if: ${{ !failure() && !cancelled() && !inputs.only_docker }}
151154
needs: [bump-version-generate-changelog]
152-
153155
runs-on: ubuntu-latest
154-
155156
steps:
156157
- name: Print variables
157158
run: |
@@ -160,11 +161,9 @@ jobs:
160161
161162
build-test-package:
162163
name: Build, Test, Package
163-
if: ${{ !failure() && !cancelled() }}
164+
if: ${{ !failure() && !cancelled() && !inputs.only_docker }}
164165
needs: [bump-version-generate-changelog]
165-
166166
uses: dbt-labs/dbt-release/.github/workflows/build.yml@main
167-
168167
with:
169168
sha: ${{ needs.bump-version-generate-changelog.outputs.final_sha }}
170169
version_number: ${{ inputs.version_number }}
@@ -174,19 +173,15 @@ jobs:
174173
package_test_command: ${{ inputs.package_test_command }}
175174
test_run: ${{ inputs.test_run }}
176175
nightly_release: ${{ inputs.nightly_release }}
177-
178176
secrets:
179177
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
180178
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
181179

182180
github-release:
183181
name: GitHub Release
184-
if: ${{ !failure() && !cancelled() }}
185-
182+
if: ${{ !failure() && !cancelled() && !inputs.only_docker }}
186183
needs: [bump-version-generate-changelog, build-test-package]
187-
188184
uses: dbt-labs/dbt-release/.github/workflows/github-release.yml@main
189-
190185
with:
191186
sha: ${{ needs.bump-version-generate-changelog.outputs.final_sha }}
192187
version_number: ${{ inputs.version_number }}
@@ -195,34 +190,41 @@ jobs:
195190

196191
pypi-release:
197192
name: PyPI Release
198-
199-
needs: [github-release]
200-
193+
if: ${{ !failure() && !cancelled() && !inputs.only_docker }}
194+
needs: [bump-version-generate-changelog, build-test-package]
201195
uses: dbt-labs/dbt-release/.github/workflows/pypi-release.yml@main
202-
203196
with:
204197
version_number: ${{ inputs.version_number }}
205198
test_run: ${{ inputs.test_run }}
206-
207199
secrets:
208200
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
209201
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
210202

203+
docker-release:
204+
name: "Docker Release"
205+
# We cannot release to docker on a test run because it uses the tag in GitHub as
206+
# what we need to release but draft releases don't actually tag the commit so it
207+
# finds nothing to release
208+
if: ${{ !failure() && !cancelled() && (!inputs.test_run || inputs.only_docker) }}
209+
needs: [bump-version-generate-changelog, build-test-package, github-release]
210+
permissions:
211+
packages: write
212+
uses: dbt-labs/dbt-release/.github/workflows/release-docker.yml@main
213+
with:
214+
version_number: ${{ inputs.version_number }}
215+
test_run: ${{ inputs.test_run }}
216+
211217
slack-notification:
212218
name: Slack Notification
213219
if: ${{ failure() && (!inputs.test_run || inputs.nightly_release) }}
214-
215220
needs:
216221
[
217-
bump-version-generate-changelog,
218-
build-test-package,
219222
github-release,
220223
pypi-release,
224+
docker-release,
221225
]
222-
223226
uses: dbt-labs/dbt-release/.github/workflows/slack-post-notification.yml@main
224227
with:
225228
status: "failure"
226-
227229
secrets:
228230
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEV_ADAPTER_ALERTS }}

Makefile

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,11 @@ dev-uninstall: ## Uninstalls all packages while maintaining the virtual environm
1111
pip freeze | grep -v "^-e" | cut -d "@" -f1 | xargs pip uninstall -y
1212
pip uninstall -y dbt-bigquery
1313

14-
.PHONY: ubuntu-py311
15-
ubuntu-py311: ## Builds and runs an Ubuntu Python 3.11 development container
16-
docker build -f docker_dev/ubuntu.Dockerfile -t dbt-bigquery-ubuntu-py311 .
17-
docker run --rm -it --name dbt-bigquery-ubuntu-py311 -v $(shell pwd):/opt/code dbt-bigquery-ubuntu-py311
14+
.PHONY: docker-dev
15+
docker-dev:
16+
docker build -f docker/dev.Dockerfile -t dbt-bigquery-dev .
17+
docker run --rm -it --name dbt-bigquery-dev -v $(shell pwd):/opt/code dbt-bigquery-dev
1818

19-
.PHONY: ubuntu-py39
20-
ubuntu-py39: ## Builds and runs an Ubuntu Python 3.9 development container
21-
docker build -f docker_dev/ubuntu.Dockerfile -t dbt-bigquery-ubuntu-py39 . --build-arg version=3.9
22-
docker run --rm -it --name dbt-bigquery-ubuntu-py39 -v $(shell pwd):/opt/code dbt-bigquery-ubuntu-py39
23-
24-
.PHONY: ubuntu-py38
25-
ubuntu-py38: ## Builds and runs an Ubuntu Python 3.8 development container
26-
docker build -f docker_dev/ubuntu.Dockerfile -t dbt-bigquery-ubuntu-py38 . --build-arg version=3.8
27-
docker run --rm -it --name dbt-bigquery-ubuntu-py38 -v $(shell pwd):/opt/code dbt-bigquery-ubuntu-py38
19+
.PHONY: docker-prod
20+
docker-prod:
21+
docker build -f docker/Dockerfile -t dbt-bigquery .

docker/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# this image gets published to GHCR for production use
2+
ARG py_version=3.11.2
3+
4+
FROM python:$py_version-slim-bullseye as base
5+
6+
RUN apt-get update \
7+
&& apt-get dist-upgrade -y \
8+
&& apt-get install -y --no-install-recommends \
9+
build-essential=12.9 \
10+
ca-certificates=20210119 \
11+
git=1:2.30.2-1+deb11u2 \
12+
libpq-dev=13.14-0+deb11u1 \
13+
make=4.3-4.1 \
14+
openssh-client=1:8.4p1-5+deb11u3 \
15+
software-properties-common=0.96.20.2-2.1 \
16+
&& apt-get clean \
17+
&& rm -rf \
18+
/var/lib/apt/lists/* \
19+
/tmp/* \
20+
/var/tmp/*
21+
22+
ENV PYTHONIOENCODING=utf-8
23+
ENV LANG=C.UTF-8
24+
25+
RUN python -m pip install --upgrade "pip==24.0" "setuptools==69.2.0" "wheel==0.43.0" --no-cache-dir
26+
27+
28+
FROM base as dbt-bigquery
29+
30+
ARG commit_ref=main
31+
32+
HEALTHCHECK CMD dbt --version || exit 1
33+
34+
WORKDIR /usr/app/dbt/
35+
ENTRYPOINT ["dbt"]
36+
37+
RUN python -m pip install --no-cache-dir "dbt-bigquery @ git+https://github.com/dbt-labs/dbt-bigquery@${commit_ref}"

docker/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Docker for dbt
2+
This docker file is suitable for building dbt Docker images locally or using with CI/CD to automate populating a container registry.
3+
4+
5+
## Building an image:
6+
This Dockerfile can create images for the following target: `dbt-bigquery`
7+
8+
In order to build a new image, run the following docker command.
9+
```shell
10+
docker build --tag <your_image_name> --target dbt-bigquery <path/to/dockerfile>
11+
```
12+
---
13+
> **Note:** Docker must be configured to use [BuildKit](https://docs.docker.com/develop/develop-images/build_enhancements/) in order for images to build properly!
14+
15+
---
16+
17+
By default the image will be populated with the latest version of `dbt-bigquery` on `main`.
18+
If you need to use a different version you can specify it by git ref using the `--build-arg` flag:
19+
```shell
20+
docker build --tag <your_image_name> \
21+
--target dbt-bigquery \
22+
--build-arg commit_ref=<commit_ref> \
23+
<path/to/dockerfile>
24+
```
25+
26+
### Examples:
27+
To build an image named "my-dbt" that supports Snowflake using the latest releases:
28+
```shell
29+
cd dbt-core/docker
30+
docker build --tag my-dbt --target dbt-bigquery .
31+
```
32+
33+
To build an image named "my-other-dbt" that supports Snowflake using the adapter version 1.0.0b1:
34+
```shell
35+
cd dbt-core/docker
36+
docker build \
37+
--tag my-other-dbt \
38+
--target dbt-bigquery \
39+
--build-arg commit_ref=v1.0.0b1 \
40+
.
41+
```
42+
43+
## Running an image in a container:
44+
The `ENTRYPOINT` for this Dockerfile is the command `dbt` so you can bind-mount your project to `/usr/app` and use dbt as normal:
45+
```shell
46+
docker run \
47+
--network=host \
48+
--mount type=bind,source=path/to/project,target=/usr/app \
49+
--mount type=bind,source=path/to/profiles.yml,target=/root/.dbt/profiles.yml \
50+
my-dbt \
51+
ls
52+
```
53+
---
54+
**Notes:**
55+
* Bind-mount sources _must_ be an absolute path
56+
* You may need to make adjustments to the docker networking setting depending on the specifics of your data warehouse/database host.
57+
58+
---

docker/dev.Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# this image does not get published, it is intended for local development only, see `Makefile` for usage
2+
FROM ubuntu:22.04 as base
3+
4+
# prevent python installation from asking for time zone region
5+
ARG DEBIAN_FRONTEND=noninteractive
6+
7+
# add python repository
8+
RUN apt-get update \
9+
&& apt-get install -y software-properties-common=0.99.22.9 \
10+
&& add-apt-repository -y ppa:deadsnakes/ppa \
11+
&& apt-get clean \
12+
&& rm -rf \
13+
/var/lib/apt/lists/* \
14+
/tmp/* \
15+
/var/tmp/*
16+
17+
# install python
18+
RUN apt-get update \
19+
&& apt-get install -y --no-install-recommends \
20+
build-essential=12.9ubuntu3 \
21+
git-all=1:2.34.1-1ubuntu1.10 \
22+
python3.8=3.8.19-1+jammy1 \
23+
python3.8-dev=3.8.19-1+jammy1 \
24+
python3.8-distutils=3.8.19-1+jammy1 \
25+
python3.8-venv=3.8.19-1+jammy1 \
26+
python3-pip=22.0.2+dfsg-1ubuntu0.4 \
27+
python3-wheel=0.37.1-2ubuntu0.22.04.1 \
28+
&& apt-get clean \
29+
&& rm -rf \
30+
/var/lib/apt/lists/* \
31+
/tmp/* \
32+
/var/tmp/*
33+
34+
# update the default system interpreter to the newly installed version
35+
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
36+
37+
38+
FROM base as dbt-bigquery-dev
39+
40+
HEALTHCHECK CMD python3 --version || exit 1
41+
42+
# send stdout/stderr to terminal
43+
ENV PYTHONUNBUFFERED=1
44+
45+
# setup mount for local code
46+
WORKDIR /opt/code
47+
VOLUME /opt/code
48+
49+
# create a virtual environment
50+
RUN python3 -m venv /opt/venv

docker_dev/README.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

docker_dev/ubuntu.Dockerfile

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)