carpentries-incubator / docker-introduction

Reproducible Computational Environments using Containers
https://carpentries-incubator.github.io/docker-introduction/
Other
42 stars 48 forks source link

fix: Dockerfile command order in ENTRYPOINT example #215

Closed krishnakumarg1984 closed 1 month ago

krishnakumarg1984 commented 1 month ago

In the section titled The Importance of Command Order in a Dockerfile, the text states that:

This order is important for rebuilding and you typically will want to put your RUN commands before your COPY commands. For example, in an instance where you wanted to copy multiply.py into the container image instead of sum.py. If the COPY line came before the RUN line, it would need to rebuild the whole image. If the COPY line came second then it would use the cached RUN layer from the previous build and then only rebuild the COPY layer.

In the example that introduces the ENTRYPOINT command, we currently have:

RUN apk add --update python3 py3-pip python3-dev
COPY sum.py /home

This PR fixes the order as per the recommendation earlier in this lesson by interchanging these two lines.