-
Notifications
You must be signed in to change notification settings - Fork 18
Docker: multi-stage build Prefect Agent image #975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
aspeddro
wants to merge
4
commits into
main
Choose a base branch
from
staging/base-dockerfile
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5ed8a87 to
e2ad8fb
Compare
Contributor
|
@aspeddro esse pull request tem conflitos 😩 |
d78ba73 to
da3b96e
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Esse PR é experimento para tentar diminuir o tempo de construção da imagem Docker.
Problema
Cada build da imagem leva em média ~4:50s.
A imagem tem algumas bibliotecas que não precisa ser instaladas em cada build. Acho que podemos criar um imagem com as bibliotecas instaladas e usar a imagem como referência.
Essa etapa é mais longa:
pipelines/Dockerfile
Lines 18 to 49 in 0265c6b
Multi-stage build
Vamos separar o processo em duas imagens. A primeira é uma imagem com as bibliotecas a nível de sistema, onde a instalação tem um custo alto (tempo). A segunda imagem representa é a imagem atual mas sem o processo de instalação das bibliotecas. Ainda existe o custo de pulling da imagem no registro ghcr.io, mas é um custo mais baixo.
Dockerfile.base-prefect-base-libsEssa imagem é pública em https://github.com/basedosdados/pipelines/pkgs/container/prefect-base-libs.
A imagem
prefect-base-libsé usada emDockerfile.FROM ghcr.io/basedosdados/prefect-base-libs:latestDockerfile-prefect-flowsDockerfilefaz o pull deghcr.io/basedosdados/prefect-base-libs:latest.Algumas etapas ainda estão em
Dockerfile:pipelinesTempo de construção de
Build and publish Prefect Agent imageAtualmente essa etapa leva ~4:50s. Com essa alteração o resultado foi
3m7s, uma pequena mudançaInspecionando as etapas
Olhando as etapas podemos vê qual leva mais tempo:
ghcr.io/basedosdados/prefect-base-libs:latest: 23.4sRUN curl -sSL https://install.python-poetry.org | python3 -: 11.8sRUN poetry install && dbt deps: 35.0sNotas