Overview
Cog supports using secret mounts to securely pass private registry credentials to pip during the build process, without baking them into the Docker image.Step 1: Create pip.conf
In a directory outside your Cog project, create apip.conf file with an index-url set to the registry’s URL with embedded credentials.
pip.conf
Store this file outside your project directory to prevent accidentally committing it to version control.
Step 2: Configure cog.yaml
In your project’scog.yaml file, add a setup command to run pip install with a secret configuration file mounted to /etc/pip.conf.
cog.yaml
Configuration Options
The command to run during the build process (e.g.,
pip install).An array of mount configurations for the command.
Step 3: Build with Secret
When building or pushing your model with Cog, pass the--secret option with an id matching the one specified in cog.yaml, along with a path to your local pip.conf file.
Using a secret mount allows the private registry credentials to be securely passed to the
pip install setup command, without baking them into the Docker image.Caching Behavior
To update the contents of the target secret file, you have two options:- Change the secret ID: Update both the
idvalue incog.yamland the--secretoption - Bypass the cache: Pass the
--no-cacheoption tocog build