diff --git a/content/08_dockerfiles.md b/content/08_dockerfiles.md index 83afb02e98d9d7c52f715d1122164e6a4c24ef6d..7ce3e89a1831e40cb89fb9adb85df439e465469a 100644 --- a/content/08_dockerfiles.md +++ b/content/08_dockerfiles.md @@ -285,19 +285,19 @@ alienwave_multistage 1.0 1c7f0a242c2c 4 minutes ago 12MB #### Dockerfile ```bash -FROM ubuntu:22.04 as BUILDER +FROM ubuntu:22.04 -RUN apt update -y && apt install -y golang ca-certificates -RUN go install github.com/alfg/asciicat@latest +RUN apt update -y && apt install -y golang ca-certificates && go install github.com/alfg/asciicat@latest +WORKDIR /root -FROM alpine:3.20 +ENV PATH="${PATH}:/root/go/bin" + +WORKDIR /home/Pictures -RUN apk update -COPY --from=builder /root/go/bin/asciicat /usr/bin COPY . . -ENTRYPOINT ["usr/bin/asciicat"] +ENTRYPOINT ["asciicat"] ``` #### Fabrication de l'image @@ -309,7 +309,7 @@ docker buildx build . -t asciicat:1.0 -f Dockerfile1 #### Utilisation ```bash -docker run --rm asciicat:1.0 -i gopher.png +docker run --rm asciicat:1.0 -i tux.png ``` - Quelle est la taille de l'image générée ? @@ -331,5 +331,35 @@ Donc la largeur par défaut de l'image est 80 - Quelle est la ligne de commande à exécuter pour obtenir une largeur de 40 ```bash -docker run --rm asciicat:1.0 -i gopher.png -w 40 +docker run --rm asciicat:1.0 -i cat.png -w 40 ``` + +### Partie 2 + +#### Dockerfile + +```bash +FROM ubuntu:22.04 as BUILDER + +RUN apt update -y && apt install -y golang ca-certificates +RUN go install github.com/alfg/asciicat@latest + + +FROM alpine:3.20 + +RUN apk update +COPY --from=builder /root/go/bin/asciicat /usr/bin +COPY . . + +ENTRYPOINT ["usr/bin/asciicat"] +``` + +#### Affichez la différence de taille entre l'image initiale et la _multi-stage build_ + +```bash +REPOSITORY TAG IMAGE ID CREATED SIZE +asciicat_multistage 1.0 a10aafdcc5c2 12 seconds ago 12.8MB +asciicat 1.0 5f22c52d66b2 7 minutes ago 890MB +``` + +- Le facteur de taille gagnée est de $\sim 69$ (noice) fois.