Skip to content

Commit

Permalink
feat: support private registry host (#28)
Browse files Browse the repository at this point in the history
This pull request adds support for non-default docker hosts (such as self-hosted registries or services like Amazon ECR). It introduces an optional environment variable DOCKER_REGISTRY to denote the URL of the registry. If this variable is left blank, the default registry of the docker client (probably Docker Hub) will be used.
  • Loading branch information
prehnRA authored and felixfbecker committed Mar 10, 2019
1 parent e8496fa commit b4fd322
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -16,7 +16,10 @@ Set of [semantic-release](https://github.com/semantic-release/semantic-release)
```json
{
"release": {
"verifyConditions": "semantic-release-docker",
"verifyConditions": {
"path": "semantic-release-docker",
"registryUrl": "docker.io"
},
"publish": {
"path": "semantic-release-docker",
"name": "username/imagename"
Expand All @@ -29,7 +32,7 @@ Set of [semantic-release](https://github.com/semantic-release/semantic-release)

Your credentials have to be configured with the environment variables `DOCKER_USERNAME` and `DOCKER_PASSWORD`.

In addition, you need to specify the name of the image as the `name` setting.
In addition, you need to specify the name of the image as the `name` setting in the publish step. If you need to specify a custom docker registry URL, add it as the `registryUrl` setting in the verifyConditions step.

## Plugins

Expand Down
15 changes: 12 additions & 3 deletions lib/verify.js
Expand Up @@ -7,9 +7,18 @@ module.exports = async (pluginConfig, { logger }) => {
}
}
try {
await execa('docker', ['login', '-u=' + process.env.DOCKER_USERNAME, '-p=' + process.env.DOCKER_PASSWORD], {
stdio: 'inherit',
})
await execa(
'docker',
[
'login',
pluginConfig.registryUrl || '',
'-u=' + process.env.DOCKER_USERNAME,
'-p=' + process.env.DOCKER_PASSWORD,
],
{
stdio: 'inherit',
}
)
} catch (err) {
throw new Error('docker login failed')
}
Expand Down

0 comments on commit b4fd322

Please sign in to comment.