Coder Social home page Coder Social logo

eclass / semantic-release-docker Goto Github PK

View Code? Open in Web Editor NEW
14.0 4.0 4.0 1.22 MB

semantic-release plugin to build and push docker images

License: MIT License

JavaScript 84.54% Shell 0.89% Dockerfile 14.57%
semantic-release semantic-release-plugin docker ecr

semantic-release-docker's Introduction

@eclass/semantic-release-docker

npm Node.js CI downloads Libraries.io dependency status for latest release Coverage Status Maintainability semantic-release

semantic-release plugin to tag and push docker images

Step Description
verifyConditions Verify the presence of the baseImageName, and registries options in plugin config.
prepare Tag docker images.
publish Push docker images.

Install

npm i -D @eclass/semantic-release-docker

Usage

The plugin can be configured in the semantic-release configuration file:

{
  "plugins": [
    "@semantic-release/changelog",
    "@semantic-release/npm",
    "@semantic-release/git",
    "@semantic-release/gitlab",
    "@eclass/semantic-release-docker"
  ]
}

Configuration

Options

Config

Variable Description
baseImageName Name of the previously constructed docker image. Required.
baseImageTag Name of the previously constructed docker image tag. Optional. Default "latest"
releaseImageTag Name of the docker image tag for new. Optional. Default "latest" or channel if use a custom branches or prerelase
registries Array of Registry objects. Required. Example: {"user": "DOCKER_USER", "password": "DOCKER_PASSWORD", "url": "docker.pkg.github.com", "imageName": "docker.pkg.github.com/myuser/myrepo/myapp"}
additionalTags Array of additional tags to push. Optional. Example: ["beta", "next"]

Registry

Variable Description
url Url of the docker registry. Required. Example: "docker.pkg.github.com"
imageName Name of the docker image. Required. Example: "docker.pkg.github.com/myuser/myrepo/myapp"
user Name of the environment variable used as user name for login to the docker registry. Required. Example: "DOCKER_USER"
password Name of the environment variable used as password for login to the docker registry. Required. Example: "DOCKER_PASSWORD"
skipTags Array of image tags that should not be pushed to the docker registry. Optional. Example: ["latest"]

Environment variables

Environment variables are variables. Depends of registries option.

Variable Description
DOCKER_USER username for docker registry.
DOCKER_PASSWORD password for docker registry.
DOCKER_BASE_IMAGE_TAG Name of the previously constructed docker image tag. Optional. Default "latest".
DOCKER_RELEASE_IMAGE_TAG Name of the docker image tag for new release. Optional. Default "latest" or channel if use a custom branches or prerelase

Examples

Push images to many docker registry

{
  "plugins": [
    "@semantic-release/changelog",
    "@semantic-release/npm",
    "@semantic-release/git",
    "@semantic-release/gitlab",
    [
      "@eclass/semantic-release-docker",
      {
        "baseImageName": "myapp",
        "registries": [
          {
            "url": "registry.gitlab.com",
            "imageName": "registry.gitlab.com/mygroup/myapp",
            "user": "CI_REGISTRY_USER",
            "password": "CI_REGISTRY_PASSWORD"
          },
          {
            "url": "docker.io",
            "imageName": "docker.io/myuser/myapp",
            "user": "DOCKER_REGISTRY_USER",
            "password": "DOCKER_REGISTRY_PASSWORD"
          },
          {
            "url": "docker.pkg.github.com",
            "imageName": "docker.pkg.github.com/myuser/myrepo/myapp",
            "user": "GITHUB_USER",
            "password": "GITHUB_TOKEN"
          },
          {
            "url": "123456789012.dkr.ecr.us-east-1.amazonaws.com",
            "imageName": "123456789012.dkr.ecr.us-east-1.amazonaws.com/myapp",
            "user": "AWS_DOCKER_USER",
            "password": "AWS_DOCKER_PASSWORD",
            "skipTags": ["latest"]
          }
        ],
        "additionalTags": ["next", "beta"]
      }
    ]
  ]
}
# .gitlab-ci.yml
release:
  image: node:alpine
  stage: release
  before_script:
    - docker build -t myapp .
  script:
    - npx semantic-release
  only:
    - master
# .travis.yml
language: node_js
cache:
  directories:
    - ~/.npm
node_js:
  - '12'
stages:
  - test
  - name: deploy
    if: branch = master
jobs:
  include:
    - stage: test
      script: npm t
    - stage: deploy
      before_script: docker build -t myapp .
      script: npx semantic-release

License

MIT

semantic-release-docker's People

Contributors

addono avatar lgaticaq avatar meesvandongen avatar renovate-bot avatar renovate[bot] avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

semantic-release-docker's Issues

Not able to upload images to aws ecr.

2021-07-14T11:04:13.562Z semantic-release:plugins options for @eclass/semantic-release-docker/prepare: { baseImageName: 'image_name',
registries:
[ { url: 'xxxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com',
imageName: 'xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/image_name',
user: 'AWS_DOCKER_USER',
password: 'AWS_DOCKER_PASSWORD' } ] }
[11:04:25 AM] [semantic-release] ��� ��� EDOCKERLOGIN Error login to docker registry.
Try login to docker registry.
{ AggregateError:
SemanticReleaseError: Error login to docker registry.
at module.exports (/node_modules/@eclass/semantic-release-docker/src/get-error.js:14:10)
at module.exports (/node_modules/@eclass/semantic-release-docker/src/verify.js:38:23)
at /usr/local/lib/node_modules/semantic-release/lib/plugins/pipeline.js:54:11
at process._tickCallback (internal/process/next_tick.js:68:7) name: �[32m'AggregateError'�[39m }

Allow specify other original image name/tag than latest

Hello.
I generally have an image with name my-base-image:<commit_hash> in my CI pipelines and don't have a "latest" tag.

I found that your plugin is hardcoding the "latest" part in the original image when doing docker tag, resulting in an error because I dont have latest tag.

It would be nice to be able to specify the full original name or a different original tag.

The plugin could then create two tags automatically: the latest and the semantic version one.

For now the workaround was to create a "latest" tag myself before calling semantic-release.

Thank you.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency eslint-plugin-import to v2.29.1
  • chore(deps): update dependency eslint-plugin-sonarjs to v0.25.1
  • chore(deps): update dependency node to v17.9.1 (node, @types/node)
  • chore(deps): update actions/cache action to v4
  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update commitlint monorepo to v19 (major) (@commitlint/cli, @commitlint/config-conventional)
  • chore(deps): update dependency @eclass/eslint-config to v4
  • chore(deps): update dependency chai to v5
  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency eslint-config-prettier to v9
  • chore(deps): update dependency eslint-plugin-array-func to v5
  • chore(deps): update dependency eslint-plugin-jsdoc to v48
  • chore(deps): update dependency eslint-plugin-n to v17
  • chore(deps): update dependency eslint-plugin-prettier to v5
  • chore(deps): update dependency eslint-plugin-security to v3
  • chore(deps): update dependency eslint-plugin-sonarjs to v1
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency lint-staged to v15
  • chore(deps): update dependency node to v20 (node, @types/node)
  • chore(deps): update dependency prettier to v3
  • chore(deps): update github artifact actions to v4 (major) (actions/download-artifact, actions/upload-artifact)
  • chore(deps): update mcr.microsoft.com/vscode/devcontainers/javascript-node docker tag to v1
  • fix(deps): update dependency dockerode to v4
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

dockerfile
.devcontainer/Dockerfile
  • mcr.microsoft.com/vscode/devcontainers/javascript-node 0-16-bullseye
.devcontainer/base.Dockerfile
  • node 16-bullseye
github-actions
.github/workflows/nodejs.yml
  • actions/checkout v3
  • actions/setup-node v3
  • actions/cache v3
  • actions/upload-artifact v3
  • actions/checkout v3
  • actions/setup-node v3
  • actions/cache v3
  • actions/download-artifact v3
  • actions/checkout v3
  • actions/setup-node v3
  • actions/cache v3
npm
package.json
  • @semantic-release/error ^3.0.0
  • aggregate-error ^3.1.0
  • dockerode ^3.3.1
  • @commitlint/cli 17.6.3
  • @commitlint/config-conventional 17.6.3
  • @eclass/eslint-config 3.0.1
  • @eclass/semantic-release-npm-github-config 4.0.0
  • @semantic-release/changelog 6.0.3
  • @semantic-release/git 10.0.1
  • @types/chai 4.3.5
  • @types/dockerode 3.3.18
  • @types/mocha 9.1.1
  • @types/mock-require 2.0.1
  • @types/node 17.0.17
  • @types/semantic-release 20.0.1
  • chai 4.3.7
  • eslint 8.36.0
  • eslint-config-prettier 8.8.0
  • eslint-plugin-array-func 3.1.8
  • eslint-plugin-eslint-comments 3.2.0
  • eslint-plugin-import 2.27.5
  • eslint-plugin-jsdoc 37.9.7
  • eslint-plugin-n 14.0.0
  • eslint-plugin-prettier 4.2.1
  • eslint-plugin-promise 6.1.1
  • eslint-plugin-security 1.7.1
  • eslint-plugin-sonarjs 0.19.0
  • eslint-plugin-standard 5.0.0
  • husky 7.0.4
  • lint-staged 12.5.0
  • mocha 9.2.2
  • mock-require 3.0.3
  • nyc 15.1.0
  • nyc-config-common 1.0.1
  • prettier 2.8.8
  • semantic-release 19.0.5
  • typescript 4.9.5
  • semantic-release >=18.0.0
  • node >=14.17.0
nvm
.nvmrc
  • node 17.4.0

  • Check this box to trigger a request for Renovate to run again on this repository

Is it possible to pass dynamically the name of the previous built image?

Hi,

I have a node project served through a docker container. I build my docker image once in my CI and I push it to my registry with the commit hash as image name. This way I can use this temporary build as a cache image. at the end of the pipeline, I need to release it through tags major.minor.fix and latest.
Problem is the plugin will need to pull the image first, and I can't rely on latest because latest can be modified during while the pipeline isn't finished. I need to pass my cache image instead.

Do you have an idea on how to do this?

More explicit error messages

Hi. First of all, thank you for this great project.

One of my pain points when using it, are the error messages, which are very generic. For example:

 [3:47:28 PM] [semantic-release] › ✔  Completed step "fail" of plugin "@semantic-release/github"
[3:47:28 PM] [semantic-release] › ✖  EDOCKERIMAGETAG Error tag docker image.
Error tag docker image. Check credentials in registries.

With this, I only know there was an error tagging the image, but I have no idea what the error was.

I was like 2h of trial and error, in a project before understanding that I was defining the "baseImageTag" property in the wrong format.

I think it would be more helpful to output the error message directly from the docker daemon.

I say, that, the original error is being supressed in the code:

 } catch (err) {
    throw new AggregateError([getError('EDOCKERIMAGETAG', ctx)])
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.