Installing private Python packages in Docker images
The usual way to get this wrong is to pass your token as a build argument. It works, but docker history shows build args, and a file written in one layer stays in the image even if a later step deletes it. If the image is ever pushed somewhere, so is your token. BuildKit secret mounts avoid that. The secret is available to a single RUN step and is never written to a layer. This needs a reasonably recent Docker (BuildKit with Dockerfile syntax 1.10 or later). ...