- Notifications
You must be signed in to change notification settings - Fork0
Zero-Configuration Docker Publishing from npm
License
vanioinformatika/docker-publish
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Do not forgetinstalling docker and runningdocker login before using it!
Install:
npm i -D @vanioinformatika/docker-publishUsing 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-publishThere 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.
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.
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:latestv1.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.5If 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-gb4c008bv1.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:0bd4c74Where0bd4c74 is the last commit id.
About
Zero-Configuration Docker Publishing from npm
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.