-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
58 lines (44 loc) · 1.49 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
ARG PYTHON_VERSION
FROM python:${PYTHON_VERSION}-slim-bullseye AS base
ENV PYTHONUNBUFFERED=1 \
# prevents python creating .pyc files
PYTHONDONTWRITEBYTECODE=1 \
# make poetry install to this location
POETRY_HOME="/opt/poetry" \
# do not ask any interactive question
POETRY_NO_INTERACTION=1 \
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv" \
# DBT env vars
DBT_PROFILES_DIR="." \
DBT_PROJECT_DIR="." \
DBT_DATASET="Overwrite at runtime"
# Prepend poetry and venv to path
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
FROM base AS builder
# Install OS dependencies
RUN apt-get update && \
apt-get install -qq -y curl --fix-missing --no-install-recommends && \
curl -sSL https://install.python-poetry.org | python3 - --version 1.8.3 && \
rm -rf /var/lib/apt/lists/*
ENV PATH="$PATH:$POETRY_HOME/bin"
# Copy Poetry files
WORKDIR /dbt
COPY ./poetry.lock ./pyproject.toml ./
RUN poetry config virtualenvs.create true && \
poetry config virtualenvs.in-project true && \
poetry install --no-cache --no-interaction --no-root --only main && \
rm -rf ~/.cache/pypoetry/artifacts
FROM base AS dbt
# Copy in pre-built .venv
COPY --from=builder /dbt/.venv /dbt/.venv
# Update OS dependencies
RUN apt-get update && \
rm -rf /var/lib/apt/lists/*
# Copy repo code
COPY . .
WORKDIR /
RUN ln -s /dbt/.venv/bin/dbt /bin/dbt && \
dbt deps && \
dbt parse
CMD ["/bin/bash", "-c", "echo 'Expecting commands to be passed in.' && exit 1"]