UM DOCKERFILE!!!— Imagens Docker multi-stage para múltiplas arquiteturas

Pedro Paulo dos Santos
Jul 23 · 8 min read
Image for post
Image for post
Fonte: New Zealand Defence Force — Flickr: NZ Defence Force assistance to OP Rena, CC BY 2.0, https://commons.wikimedia.org/w/index.php?curid=17663078 (fique calmo, vamos começar a desvirar o barco!)

Oi! Eu me chamo Pedro Paulo e estou de volta para compartilhar com vocês um problema que tive com o Docker e como eu tive que resolver.

Image for post
Image for post
Fonte: kamarada.github.io
Instalação do Docker no RasPi (fonte: https://www.edivaldobrito.com.br/docker-no-raspberry-pi-com-raspbian)
docker run -e PASSWORD=SENHA --rm -p 8787:8787 rocker/rstudio
docker run --rm -ti rocker/r-base

O que é o buildx?


Especificações técnicas

Image for post
Image for post
Interface do Windows
curl -fsSL https://test.docker.com -o test-docker.sh
export DOCKER_CLI_EXPERIMENTAL=enabled

Imagens Multi-arquiteturas

Image for post
Image for post
Fonte: https://thenewstack.io/docker-offers-enterprise-containers-service-package/
docker buildx build --tag r-base:latest --platform  linux/amd64,linux/arm64 .
docker run -it r-base

De quantos você precisa?

Image for post
Image for post
Fonte: https://gofore.com/en/documentation-chaos-avoidable-software-projects-part-1/

Multi-Stage build!

Estágios em série

Image for post
Image for post
Fonte: https://www.business2community.com/marketing/4-stages-effective-lead-generation-process-01297359
Multi-Stage seriado
# build da imagemdocker build -t teste .# levantando o container e abrindo o terminal dele.docker run -it teste# pegando o conteúdo arquivo log.txtcat log.txt
Montando a base...
Build a branch-1...
Build a branch-2...
Build a branch-3 e encerrando.
docker build --target branch-1 -t teste .
docker run -it teste
cat log.txt
Montando a base...   
Build a branch-1...

Estágios paralelos

Image for post
Image for post
Fonte: https://pipocasclub.com.br/2020/07/14/dark-elenco-e-criadores-se-despedem-da-serie/. Propriedade: Netflix. (Olha ai! a série na prática!!)
Multi-Stage paralelo
docker build -t teste .
docker run -it teste
cat log.txt
Montando a base...
Build a branch-3.
docker build --target branch-2 -t teste .
docker run -it teste
cat log.txt
# devemos ver:
Montando a base...
Build a branch-2...

Estágios condicionais

Image for post
Image for post
Fonte: https://wallpapercave.com/eevee-evolutions-wallpaper. (Aquela condicional de geek…)
Multi-Stage condicional
docker build --build-arg src=2 -t teste .
docker run -it teste
cat log.txt
# saída do cat
Montando a base...
Build a branch-2...
Build the final.

Estágios em série com condicional

Image for post
Image for post
Fonte: https://imgur.com/gallery/FlF4f
Multi-stage paralelo com serie condicional
docker build --build-arg src=4 -t teste .
docker run -it teste
cat log.txt
# saída do cat
Montando a base...
Build a branch-3...
Build a branch-4...
Build the final.

COPY de outro estágio

Image for post
Image for post
Fonte: https://notaalta.espm.br/fala-professor/como-assim-direito-de-colar/
docker build --build-arg src=4 -t teste .
docker run -it teste
cat log.txt
# saída do cat
Montando a base...
Build a branch-1...
Build a branch-2...
Build a branch-3...
Build a branch-4...
Build the final.

Aplicação multi-stage para múltiplas arquiteturas

Image for post
Image for post
Fonte: https://makeameme.org/meme/glory-glory-everywhere
docker buidlx build --build-arg src=4 --platform linux/amd64 -t test .
docker run -it teste
library('epiDisplay')
library('sp')

Obrigado!

Data Hackers

Blog oficial da comunidade Data Hackers

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store