-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,9 @@ jobs: | |
url: ${{ vars.PYPI_PROJECT_URL }} | ||
permissions: | ||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | ||
outputs: | ||
version: ${{ steps.release-inputs.outputs.version }} | ||
is-docker-release: ${{ steps.semver.outputs.is-pre-release == 0 }} | ||
|
||
steps: | ||
- name: Check out repository | ||
|
@@ -43,6 +46,13 @@ jobs: | |
version=$(hatch version) | ||
archive_name=dbt-postgres-$version-${{ inputs.deploy-to }} | ||
echo "archive-name=$archive_name" >> $GITHUB_OUTPUT | ||
echo "version=version" >> $GITHUB_OUTPUT | ||
- name: Audit version to determine if it is a pre-release | ||
id: semver | ||
uses: dbt-labs/actions/[email protected] | ||
with: | ||
version: ${{ steps.release-inputs.outputs.version }} | ||
|
||
- name: Build `dbt-postgres` | ||
uses: dbt-labs/dbt-adapters/.github/actions/build-hatch@main | ||
|
@@ -54,3 +64,14 @@ jobs: | |
with: | ||
pypi-repository-url: ${{ vars.PYPI_REPOSITORY_URL }} | ||
archive-name: ${{ steps.release-inputs.outputs.archive-name }} | ||
|
||
docker-release: | ||
name: "Docker Release" | ||
needs: [release] | ||
if: ${{ needs.release.outputs.is-docker-release }} | ||
permissions: | ||
packages: write | ||
uses: dbt-labs/dbt-release/.github/workflows/release-docker.yml@main | ||
with: | ||
package: "dbt-postgres" | ||
version_number: ${{ needs.release.outputs.version }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
ARG build_for=linux/amd64 | ||
|
||
FROM --platform=$build_for python:3.10.7-slim-bullseye as base | ||
Check warning on line 3 in docker/Dockerfile Wiz Inc. (266a8a9c32) / Wiz IaC ScannerUsing Platform Flag with FROM Command
Raw output
|
||
|
||
# ref is updated automatically every final release via bumpversion | ||
ARG [email protected] | ||
|
||
RUN apt-get update \ | ||
Check warning on line 8 in docker/Dockerfile Wiz Inc. (266a8a9c32) / Wiz IaC ScannerApt Get Install Pin Version Not Defined
Raw output
Check warning on line 8 in docker/Dockerfile Wiz Inc. (266a8a9c32) / Wiz IaC ScannerApt Get Install Pin Version Not Defined
Raw output
Check warning on line 8 in docker/Dockerfile Wiz Inc. (266a8a9c32) / Wiz IaC ScannerApt Get Install Pin Version Not Defined
Raw output
Check warning on line 8 in docker/Dockerfile Wiz Inc. (266a8a9c32) / Wiz IaC ScannerApt Get Install Pin Version Not Defined
Raw output
Check warning on line 8 in docker/Dockerfile Wiz Inc. (266a8a9c32) / Wiz IaC ScannerApt Get Install Pin Version Not Defined
Raw output
Check warning on line 8 in docker/Dockerfile Wiz Inc. (266a8a9c32) / Wiz IaC ScannerApt Get Install Pin Version Not Defined
Raw output
Check warning on line 8 in docker/Dockerfile Wiz Inc. (266a8a9c32) / Wiz IaC ScannerApt Get Install Pin Version Not Defined
Raw output
|
||
&& apt-get dist-upgrade -y \ | ||
&& apt-get install -y --no-install-recommends \ | ||
git \ | ||
ssh-client \ | ||
software-properties-common \ | ||
make \ | ||
build-essential \ | ||
ca-certificates \ | ||
libpq-dev \ | ||
&& apt-get clean \ | ||
&& rm -rf \ | ||
/var/lib/apt/lists/* \ | ||
/tmp/* \ | ||
/var/tmp/* | ||
|
||
ENV PYTHONIOENCODING=utf-8 | ||
ENV LANG=C.UTF-8 | ||
|
||
RUN python -m pip install --upgrade pip setuptools wheel --no-cache-dir | ||
|
||
WORKDIR /usr/app/dbt/ | ||
ENTRYPOINT ["dbt"] | ||
|
||
FROM base as dbt-postgres | ||
Check failure on line 32 in docker/Dockerfile Wiz Inc. (266a8a9c32) / Wiz IaC ScannerMissing User Instruction
Raw output
Check notice on line 32 in docker/Dockerfile Wiz Inc. (266a8a9c32) / Wiz IaC ScannerHealthcheck Instruction Missing
Raw output
|
||
RUN python -m pip install --no-cache-dir "dbt-postgres @ git+https://github.com/dbt-labs/${dbt_postgres_ref}" | ||
Check warning on line 33 in docker/Dockerfile Wiz Inc. (266a8a9c32) / Wiz IaC ScannerUnpinned Package Version in Pip Install
Raw output
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Docker for dbt | ||
This docker file is suitable for building dbt Docker images locally or using with CI/CD to automate populating a container registry. | ||
|
||
|
||
## Building an image: | ||
This Dockerfile can create images for the following target: `dbt-postgres` | ||
|
||
In order to build a new image, run the following docker command. | ||
``` | ||
docker build --tag <your_image_name> --target dbt-postgres <path/to/dockerfile> | ||
``` | ||
--- | ||
> **Note:** Docker must be configured to use [BuildKit](https://docs.docker.com/develop/develop-images/build_enhancements/) in order for images to build properly! | ||
--- | ||
|
||
By default the images will be populated with the most recent release of `dbt-postgres`. If you need to use a different version you can specify it by git ref using the `--build-arg` flag: | ||
``` | ||
docker build --tag <your_image_name> \ | ||
--target dbt-postgres \ | ||
--build-arg dbt_postgres_ref=<git_ref> \ | ||
<path/to/dockerfile> | ||
``` | ||
|
||
### Examples: | ||
To build an image named "my-dbt" that supports Snowflake using the latest releases: | ||
``` | ||
cd dbt-core/docker | ||
docker build --tag my-dbt --target dbt-postgres . | ||
``` | ||
|
||
To build an image named "my-other-dbt" that supports Snowflake using the adapter version 1.0.0b1: | ||
``` | ||
cd dbt-core/docker | ||
docker build \ | ||
--tag my-other-dbt \ | ||
--target dbt-postgres \ | ||
--build-arg [email protected] \ | ||
. | ||
``` | ||
|
||
## Special cases | ||
There are a few special cases worth noting: | ||
|
||
* If you need to build against another architecture (linux/arm64 in this example) you can override the `build_for` build arg: | ||
``` | ||
docker build --tag my_dbt \ | ||
--target dbt-postgres \ | ||
--build-arg build_for=linux/arm64 \ | ||
<path/to/dockerfile> | ||
``` | ||
|
||
Supported architectures can be found in the python docker [dockerhub page](https://hub.docker.com/_/python). | ||
|
||
## Running an image in a container: | ||
The `ENTRYPOINT` for this Dockerfile is the command `dbt` so you can bind-mount your project to `/usr/app` and use dbt as normal: | ||
``` | ||
docker run \ | ||
--network=host \ | ||
--mount type=bind,source=path/to/project,target=/usr/app \ | ||
--mount type=bind,source=path/to/profiles.yml,target=/root/.dbt/profiles.yml \ | ||
my-dbt \ | ||
ls | ||
``` | ||
--- | ||
**Notes:** | ||
* Bind-mount sources _must_ be an absolute path | ||
* You may need to make adjustments to the docker networking setting depending on the specifics of your data warehouse/database host. | ||
|
||
--- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# - VERY rudimentary test script to run latest + specific branch image builds and test them all by running `--version` | ||
# TODO: create a real test suite | ||
|
||
clear \ | ||
&& echo "\n\n"\ | ||
"########################################\n"\ | ||
"##### Testing dbt-postgres latest #####\n"\ | ||
"########################################\n"\ | ||
&& docker build --tag dbt-postgres \ | ||
--target dbt-postgres \ | ||
docker \ | ||
&& docker run dbt-postgres --version \ | ||
\ | ||
&& echo "\n\n"\ | ||
"#########################################\n"\ | ||
"##### Testing dbt-postgres-1.0.0b1 #####\n"\ | ||
"#########################################\n"\ | ||
&& docker build --tag dbt-postgres-1.0.0b1 \ | ||
--target dbt-postgres \ | ||
--build-arg [email protected] \ | ||
docker \ | ||
&& docker run dbt-postgres-1.0.0b1 --version |