Skip to content

Commit

Permalink
DOCKER_CONFIG env variable support
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu committed Nov 19, 2023
1 parent d172937 commit 5fb46cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ const getDefaultOptions = () => {
mutableDefaults: true
};
// Support for private registry
if (existsSync(join(homedir(), ".docker", "config.json"))) {
if (
process.env.DOCKER_CONFIG ||
existsSync(join(homedir(), ".docker", "config.json"))
) {
const configData = readFileSync(
join(homedir(), ".docker", "config.json"),
process.env.DOCKER_CONFIG || join(homedir(), ".docker", "config.json"),
"utf-8"
);
if (configData) {
Expand Down Expand Up @@ -154,7 +157,10 @@ const getDefaultOptions = () => {
const authPayload = {
username: process.env.DOCKER_USER,
email: process.env.DOCKER_EMAIL,
serveraddress: process.env.DOCKER_SERVER_ADDRESS
serveraddress: process.env.DOCKER_SERVER_ADDRESS.replace(
"http://",
""
).replace("https://", "")
};
if (process.env.DOCKER_USER === "<token>") {
authPayload.IdentityToken = process.env.DOCKER_PASSWORD;
Expand Down
1 change: 1 addition & 0 deletions docs/ENV.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The following environment variables are available to configure the bom generatio
| ASTGEN_IGNORE_DIRS | Comma separated list of directories to ignore while analyzing using babel. The environment variable is also used by atom and astgen. |
| ASTGEN_IGNORE_FILE_PATTERN | Ignore regex to use |
| PYPI_URL | Override pypi url. Default: https://pypi.org/pypi/ |
| DOCKER_CONFIG | Alternative path to $HOME/.docker/config.json |
| DOCKER_AUTH_CONFIG | Perform docker login prior to invoking cdxgen. The file $HOME/.docker/config.json would be automatically read if available. Base64 encoded (json) with credentials: `{'username': string, 'password': string, 'email': string, 'serveraddress' : string}`. Alternatively, set the below 4 environment variables. |
| DOCKER_USER | Docker username |
| DOCKER_PASSWORD | Docker password |
Expand Down

0 comments on commit 5fb46cd

Please sign in to comment.