Skip to content

Commit 48985b6

Browse files
authored
Merge pull request #91 from bqbooster/docker-image
Build a docker image to improve CI build
2 parents b4268ef + 5ba4eb1 commit 48985b6

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build base image for CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- main
8+
paths:
9+
- 'Dockerfile'
10+
- 'Makefile'
11+
12+
jobs:
13+
build-base-image:
14+
name: Build base image
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
ref: ${{ github.event.pull_request.head.sha }} # Check out the code of the PR
25+
26+
- name: Build base image
27+
run: |
28+
make build
29+

Dockerfile

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Build args and base image
2+
ARG build_for=linux/amd64
3+
FROM --platform=$build_for python:3.13.1-slim-bullseye
4+
LABEL maintainer="Kayrnt"
5+
LABEL description="dbt development environment with BigQuery support"
6+
7+
# Set environment variables for proper encoding and locale
8+
ENV PYTHONIOENCODING=utf-8 \
9+
LANG=en_US.UTF-8 \
10+
LANGUAGE=en_US:en \
11+
LC_ALL=en_US.UTF-8
12+
13+
# Install system dependencies and set locale
14+
# Using --no-install-recommends to minimize image size
15+
RUN apt-get update -qq \
16+
&& apt-get upgrade -y \
17+
&& apt-get install -y --no-install-recommends \
18+
build-essential \
19+
wget \
20+
curl \
21+
ca-certificates \
22+
git \
23+
jq \
24+
locales \
25+
dumb-init \
26+
&& echo "UTC" > /etc/localtime \
27+
&& echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
28+
&& locale-gen \
29+
# Install dbt completion script
30+
&& wget -q https://raw.githubusercontent.com/dbt-labs/dbt-completion.bash/master/dbt-completion.bash -O ~/.dbt-completion.bash \
31+
&& echo 'source ~/.dbt-completion.bash' >> ~/.bash_profile \
32+
# Clean up
33+
&& apt-get clean \
34+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
35+
36+
# install Cargo
37+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust.sh \
38+
&& sh rust.sh -y
39+
40+
# Add Cargo to PATH
41+
ENV PATH="/root/.cargo/bin:${PATH}"
42+
RUN cargo
43+
44+
# Update pip and install Python dependencies
45+
RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel
46+
47+
# Install dbt and related tools
48+
RUN pip install --no-cache-dir \
49+
sqlfluff \
50+
sqlfluff-templater-dbt \
51+
dbt-bigquery \
52+
'sqlmesh[github,bigquery]' \
53+
&& rm -rf /usr/local/share/doc /root/.cache/
54+
55+
WORKDIR /usr/app/
56+
ENTRYPOINT ["zsh"]

Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Define the shell to use
2+
SHELL := /bin/bash
3+
4+
# Define the name of the Docker image
5+
IMAGE_NAME := dbt-bigquery-monitoring-base
6+
7+
test:
8+
poetry run pytest
9+
10+
build:
11+
docker build -t $(IMAGE_NAME):main .

0 commit comments

Comments
 (0)