Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Zero-Configuration Docker Publishing from npm

License

NotificationsYou must be signed in to change notification settings

vanioinformatika/docker-publish

Repository files navigation

TravisStandard - JavaScript Style Guidenpm downloads

Simple Docker tagging and publishing with 'npm version'


Prerequisite

Do not forgetinstalling docker and runningdocker login before using it!

Install:

npm i -D @vanioinformatika/docker-publish

Best practice

Using npm run postversion: building image, creating docker tags and push into Docker Registry with one command.

In package.json setpostversion:

"preversion": "docker -v && git push && npm install && npm test","version": "","postversion": "git push && git push --tags && docker build -t $npm_package_config_docker_ns/$npm_package_name:latest . && docker-publish"

or with hands:

docker build -t namespace/appname:latest .node ./node_modules/.bin/docker-publish

Configuration

There iszero configuration. All parameters comes from package.json:$npm_package_name and$npm_package_version variable (name and version properties).

* Maybe you want to use your own private docker repository, in this case please see the next chapter.

Customization

Optionally, in package.json you can customize your docker properties:

"version":"1.3.5","name":"docker-publish","config": {"docker": {"ns":"namespace","url":"docker.yourcompany.com:5000","name":"myapp","skip":false,"silence":false,"strictSemver":false  }}

CLI parameters could overwites package.json properties (except version number).

  • DOCKER_NS: your namespace for image;namespace/imagename:tag Default: empty

  • DOCKER_URL: your private docker repository URL;docker.yourcompany.com:5000

  • DOCKER_NAME: overwrite image name. Default: package.jsonname properties

  • DOCKER_SKIP: Skip Docker tag and push commands (dry run with logging). Default: false

  • DOCKER_SILENCE: Do not logging. Default: false

  • DOCKER_STRICT_SEMVER: Strict semantic versioning tag. Default: false. If it is true, then only one tag will be created on docker image ashttps://semver.org defined and there is no 'v' before version number.

Releasing

Best practice:postversion containsimage building anddocker-publish, and runningnpm version

Output:

docker tag docker-publish:latest docker-publish:v1docker tag docker-publish:latest docker-publish:v1.3docker tag docker-publish:latest docker-publish:v1.3.5docker tag docker-publish:latest docker-publish:v1.3.5-RELEASE-g993df1bdocker tag docker-publish:latest docker-publish:latestdocker push docker-publish:v1docker push docker-publish:v1.3docker push docker-publish:v1.3.5docker push docker-publish:v1.3.5-RELEASE-g993df1bdocker push docker-publish:latest

v1.3.5-RELEASE-g993df1b: v1.3.5 - your version number from project.json, g993df1b - git commit ID (7 chars)

If DOCKER_STRICT_SEMVER, strictSemver istrue, then:

docker tag docker-publish:latest docker-publish:1.3.5docker push docker-publish:1.3.5

Snapshot

If you want to publish asnapshot, the image will be tagged with git commit id, and the commit's number since last version, and pushed. If DOCKER_STRICT_SEMVER, strictSemver istrue, then snapshot is not available.

Output:

docker tag docker-publish:latest docker-publish:v1.3.4-5-gb4c008bdocker push docker-publish:v1.3.4-1-gb4c008b

v1.3.5-RELEASE-g993df1b: v1.3.5 - your version number from project.json, 5 - commit's number since v1.3.4 tag, gb4c008b - last (fifth) git commit ID (7 chars

If you have never tagged git commit, then tag shows:

skipped: docker tag docker-publish:latest docker-publish:0bd4c74skipped: docker push docker-publish:0bd4c74

Where0bd4c74 is the last commit id.

About

Zero-Configuration Docker Publishing from npm

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp