Containerize everything | build docker images with ease| step by step beginner tutorial

Sdílet
Vložit
  • čas přidán 28. 08. 2024

Komentáře • 4

  • @dmbrv
    @dmbrv Před 8 měsíci

    Great video.

  • @Powerdrohne
    @Powerdrohne Před 8 měsíci +1

    Thanks for the nice tutorial!
    I would like to mention to optimize the layer order in the build step a bit to actually benefit from the Docker cache:
    First, add the requirements.txt file and then immediately run the pip install command. Then add the entire source code with the RUN command or the ENTRYPOINT at the end.
    The advantage of this sequence is that changes in the source code (which tend to occur more frequently than changes in the requirements.txt) do not require the layers above to be rebuilt.
    In practice, this also works if you simply add the entire source code at the end, which could point to this advantage even more:
    ---------------------------
    FROM python:3-slim
    WORKDIR /app
    ADD requirements.txt ./
    RUN pip install -r requirements.txt
    CMD ["python", "-u", "app.py"]
    ADD . ./
    ---------------------------

    • @techwithmarco
      @techwithmarco  Před 7 měsíci +1

      Really good addition! Thanks for that :)
      I wanted to concentrate on building the image without much disturbance of other points to focus on.