npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vanioinformatika/docker-publish

v2.1.2

Published

Simple Docker tagging and publishing from npm

Downloads

3

Readme

Prerequisite

Do not forget installing docker and running docker 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 set postversion:

"preversion": "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 is zero 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.json name 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 as https://semver.org defined and there is no 'v' before version number.

Releasing

Best practice: postversion contains image building and docker-publish, and running npm version

Output:

docker tag docker-publish:latest docker-publish:v1
docker tag docker-publish:latest docker-publish:v1.3
docker tag docker-publish:latest docker-publish:v1.3.5
docker tag docker-publish:latest docker-publish:v1.3.5-RELEASE-g993df1b
docker tag docker-publish:latest docker-publish:latest
docker push docker-publish:v1
docker push docker-publish:v1.3
docker push docker-publish:v1.3.5
docker push docker-publish:v1.3.5-RELEASE-g993df1b
docker 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 is true, then:

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

Snapshot

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

Output:


docker tag docker-publish:latest docker-publish:v1.3.4-5-gb4c008b
docker 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:0bd4c74
skipped: docker push docker-publish:0bd4c74

Where 0bd4c74 is the last commit id.