As you develop your agents, you might discover that you have credentials that you need to store on disk that you don't want stored in your Git Repo or baked into your container image.
Examples:
- File based LLM Credentials Files (e.g. Google Vertex)
- Certificates or private keys needed for communication with external APIs
The privatecredentials/ folder give you a quick place to put these files in development.
Protection
- The .dockerignore file excludes the entire folder to keep it out of the build process.
- The .gitignore files only allows the
.gitkeepfile -- since git doesn't track empty folders.
Mounted Volume
The docker compose file mounts the privatecredentials/ into the container as /privatecredentials/. The running container will have access to the untracked files that you have in your development environment.
Why Not Use Docker Watch
The syncing feature of Docker Watch isn't used for these reasons:
- docker watch adheres to the rules in
.dockerignoreand therefore won't see the credentials - even if it did, docker watch doesn't do an initial sync when the container start and will only sync changes that occur while the service is running
For each file based credential, do the following:
- Put the file (e.g.
example-creds.txt) into theprivatecredentials/folder - In your
.envfile, create an environment variable for the credential (e.gEXAMPLE_CREDENTIAL=/privatecredentials/example-creds.txt) that your agent will use to reference the location at runtime - In your agent, use the environment variable wherever you need the path to the credential
Google Vertex SDK uses the GOOGLE_APPLICATION_CREDENTIALS environment variable to locate your credentials file.
Do the following:
- Put
service-account-key.json(orgoogle-credentials.json) into theprivatecredentials/folder - In your
.envfile, defineGOOGLE_APPLICATION_CREDENTIALS=/privatecredentials/service-account-key.json - Vertex SDK automatically references the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable.
If your agent calls a remote API that requires a client certificate, your agent will need the public certificate to be available.
For example, let's assume you have a cert named my_remote_api_certificate.cer
Do the following:
- Put
my_remote_api_certificate.cerinto theprivatecredentials/folder - In your
.envfile, defineMY_REMOTE_API_CERTIFICATE=/privatecredentials/my_remote_api_certificate.cer - Have the HTTP client in your agent access the file using the ENV value
In production, you will need to make the file based credentials available to the application and use the environment variable to define where the container can access them.
There are a number of approaches:
- Use Kubernetes Secrets or Docker Secrets mounted as data volumes that will let your app see them as files on the filesystem
- Use the secrets management feature of your cloud hosting environment (Google Cloud Secrets, AWS Secrets Manager, etc)
- Use a 3rd party secrets management platform
- Manually place the credentials on your Docker hosts and mount volumes to map the credentials to the container (Less secure)