1.0.1 • Published 3 years ago

@codedependant/release-config-docker v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

release-config-docker

Semantic release shareable configuration for releasing docker images

Usage

// package.json
{
  "release": {
    "branches": ["main"],
    "extends": "@codedependant/release-config-docker",
    "dockerImage": "custom-image-name"
  }
}

Monorepos

For monorepos it may be desireable to use the same Dockerfile for multiple deployments. This is possible by pointing the dockerfile option to its location relative to the sub project

// package.json
{
  "release": {
    "branches": ["main"],
    "extends": "@codedependant/release-config-docker",
    "dockerFile": "../../Dockerfile"
  }
}

Alternatively

// release.config.js
const path = require('path')
module.exports = {
  branches : ['main'],
  extends: '@codedependant/release-config-docker',
  dockerFile: path.join(__dirname, '..', '..', 'Dockerfile')
}

Options

OptionDescriptionDefault
dockerTagsOptional. An array of strings allowing to specify additional tags to apply to the image. Supports templatinglatest, {major}-latest, {version}
dockerImageOptional. The name of the image to release.Parsed from package.json name property
dockerRegistryOptional. The hostname and port used by the the registry in format hostname[:port]. Omit the port if the registry uses the default portnull (dockerhub)
dockerProjectOptional. The project or repository name to publish the image toFor scoped packages, the scope will be used, otherwise null
dockerDockerfileOptional. The path, relative to $PWD to a Docker file to build the target image withDockerfile
dockerContextOptional. A path, relative to $PWD to use as the build context A.
dockerLoginOptional. Set to false it by pass docker login if the docker daemon is already authorizedfalse
dockerArgsOptional. Include additional values for docker's build-arg. Supports templating
dockerPublishOptional. Automatically push image tags during the publish phase.true

Tag Template

Simple template tag {} values may be used. Dot notation can be used to extract values from objects

VariableDescriptionType
previousObject with major, minor, patch semver information of the last release published.Object
nextObject with major, minor, patch semver information of the release to be published.Object
git_shaThe commit SHA of the current releaseString
git_tagThe git tag of the current releaseString
release_typeThe severity type of the current build (major, minor, patch)String
relase_notesThe release notes blob associated with the releaseString
versionSever string of the version being builtString
majorThe major version of the next releaseNumber
minorThe minor version of the next releaseNumber
patchThe patch version of the next releaseNumber
envEnvironment variables that were set at build timeObject
pkgValues parsed from package.jsonObject
buildThe Random build hash representing the current execution contextString
nowCurrent timestamp is ISO 8601 formatString

Build Arguments

The build step will be passed a number of default build arguments. If the value of the build argument is true The build argument value will be omitted allowing the value to be pulled from an environment variable

// package.json

{
  "release": {
    "extends": "@codedependant/release-config-docker",
    "dockerFile": "../../Dockerfile",
    "dockerTags": ["latest", "{version}", "{major}-latest", "{major}.{minor}"],
    "dockerRegistry": "gcr.io",
    "dockerProject": "logdna-k8s",
    "dockerArgs": {
      "GITHUB_TOKEN": null
    }
  }
}
> export GITHUB_TOKEN=abc123
> docker build -t gcr.io/logdna-k8s/service-name --build-arg GITHUB_TOKEN -f ../../Dockerfile .

Default Build Arguments

Build ArgDescriptionExample
SRC_DIRECTORYThe name of the directory the build is being executedone
TARGET_PATHThe path to the current src directory relative to the project rootworkspace/one
NPM_PACKAGE_NAMEThe name of the current package the build is executing. Sans scopepackage-one
NPM_PACKAGE_SCOPEThe Scope of the current package, if present. Sans @scope
CONFIG_NAMEThe name of the image as it is being built. Sans registry.image-name
CONFIG_PROJECTThe name of the project the docker image will belong tologdna-k8s
GIT_SHAThe commit SHA of the current releaseec6e214f0
GIT_TAGThe git tag of the current releasev1.0.0