Context
When creating a Dockerfile, it is common to download artifacts, tar files, etc. from external URLs. Usually, developers will use a RUN instruction that invokes curl or wget to accomplish this. The dockerfile specification provides a baked-in alternative, the ADD instruction.
How to use
Besides copying files and directories from the build context, the ADD statement can download files from an external URL, as shown in the example below:
FROM ubuntu:latest
ADD https://github.com/roboll/helmfile/releases/download/v0.138.7/helmfile_linux_amd64 /usr/local/bin/helmfile
RUN chmod +x /usr/local/bin/helmfile
ENTRYPOINT ["/usr/local/bin/helmfile"]
Notes
- The downloaded file will have
0600as permission, which in case of a binary means that you will have to run a subsequentRUNcommand to update theexecutablebit (as shown in the example above). - If the URL is protected with authentication, you need to use
wgetorcurlinstead, since theADDinstruction doesn’t support authentication