I am writing a Dockerfile for my project like
RUN git clone https://github.com/CNA/contract.git --depth 1 --branch 20.0 /opt/CNA-contract
I would like to freeze the code at a particular commit. What is the best practice to do something like this in Docker? I see it fairly easy in buildouts something like
git clone https://github.com/CNA/contract.git --depth 1 --branch 20.0 /opt/CNA-contract commit-SHA
--depth 1 --branch <tag-name>
does the trick regardless of how old your Git is. You'll get a detached-HEAD clone, but that should be fine.