question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better Docker build image

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
beckjakecommented, Jun 9, 2020

@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/dbt has always been a 3.8.x-slim-buster-based image (I think)

0reactions
jtcohen6commented, Mar 15, 2021

I believe this was resolved by #3019

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found