Better Docker build image
See original GitHub issueDescribe the feature
Move the inline Dockerfile to a separate Dockerfile
https://github.com/fishtown-analytics/dbt/blob/dev/octavius-catto/scripts/build-dbt.py#L717-L745
Relevant: #2457
#DOCKER
Describe alternatives you’ve considered
Something like this. and it is more easy to tune and optimize.
When we need to build the image, pass those arguments with --build-arg, and we don’t need to keep a list of Dockerfiles.
ARG REQUIREMENTS_PATH
ARG REQUIREMENTS_FILE_NAME
ARG DIST_PATH
ARG WHEEL_PATH
ARG PYTHON_BASE_IMAGE="python:3.6-slim-buster"
FROM ${PYTHON_BASE_IMAGE}
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git software-properties-common make build-essential \
ca-certificates libpq-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY $REQUIREMENTS_PATH ./$REQUIREMENTS_FILE_NAME
COPY $DIST_PATH ./dist
RUN pip install --upgrade pip setuptools
RUN pip install --requirement ./$REQUIREMENTS_FILE_NAME
RUN pip install $WHEEL_PATH
RUN useradd -mU dbt_user
ENV PYTHONIOENCODING=utf-8
ENV LANG C.UTF-8
WORKDIR /usr/app
VOLUME /usr/app
USER dbt_user
ENTRYPOINT dbt
Additional context
Is this feature database-specific? Which database(s) is/are relevant? Please include any other relevant context here.
Who will this benefit?
Everyone. This helps
- maintain a better Docker image - easier to extend etc
- makes it easier to optimize in the future.
- Multi Python version images
- This can be further configured to integrate with the CI images with Multi-Stage build
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
docker build - Docker Documentation
The docker build command builds Docker images from a Dockerfile and a “context”. A build's context is the set of files located in...
Read more >How to Build an Image with the Dockerfile - SitePoint
Building the app, installing the dependencies and services, automating the deployment, and more — it all starts with the Dockerfile.
Read more >Docker Build: A Beginner's Guide to Building Docker Images
When you create a Docker container, you're adding a writable layer on top of the Docker image. You can run many Docker containers...
Read more >Tips for optimizing Docker builds - CircleCI
Ephemeral containers. The image defined by your Dockerfile should generate containers that are ephemeral. · Don't install unnecessary packages.
Read more >Six Ways to Build Docker Images Faster (Even in Seconds)
Six Ways to Build Docker Images Faster (Even in Seconds) · 1. First, we need to delete images locally so that previous runs...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@xinbinhuang I believe I did implement that change! The new Dockerfile takes the things it cares about as buildArgs.
@johnoscott The Ubuntu dockerfile you’re looking at is our test env Dockerfile. The “official” dockerfile that gets pushed to
fishtownanalytics/dbthas always been a3.8.x-slim-buster-based image (I think)I believe this was resolved by #3019