docker-image-publish
v1.4.1
Published
A script to build, tag and publish docker images with version labels and dev suffix, base on the source git branch.
Downloads
323
Readme
Docker Image Publish
A script to build, tag and publish docker images with version labels and dev suffix, based on the source git branch.
It can be configured by env vars or pakege.json entries.
It parses the source version based on SemVer and set tag version metadata based on git flow.
The env vars
APP_NAME: The name your team know and love.VERSION: The current SemVer valid version.PRODUCTION_BRANCH: Your stable branch, like "main" or "master".RC_BRANCH_PREFIX: The name prefix to identify release candidate branches.DOCKER_REG: Can be a comma separated list of registries.REG_GROUP: The repo directory where your image will be published.IS_LATEST: acceptstrue,falseor empty.
The equivalent configuration in a pakege.json
{
"name": "app-name", // Will be used if it's not a git repo with a remote named "origin".
"version": "0.1.2",
...
"docker-reg": "registry.example.com,gcr.io/my-id",
"reg-group": "group-name",
"production-branch": "main",
"scripts": {
...
"docker:build:info": "docker-build-info",
"docker:build": "npm run -s build && docker-build",
"docker:push": "docker-push",
"docker:release": "npm run -s docker:build && docker-push",
"docker:release:latest": "npm run -s docker:build --latest && docker-push --latest",
"docker:run": ". docker-common; docker run -p ${PORT:-8080}:80 $DOCKER_IMG",
"docker:run:sh": ". docker-common; docker run -p ${PORT:-8080}:80 -it $DOCKER_IMG sh",
}
...
}Optional features enabled by cli arguments
--latest: Adds a "latest" tag to the publishing list.--append-timestamp: Adds the current UTC time to the full version tag.
Using without installing
Useful for tasks inside GitLab-CI and other ephemeral environments.
curl https://ntopus.gitlab.io/docker-image-publish/publish.sh |
APP_NAME=my-app VERSION=0.0.0 PRODUCTION_BRANCH=main \
DOCKER_REG=docker.io REG_GROUP=my-name | sh -eThis will run docker-build-info && docker-build && docker-push
Debugging
If you want to know what you will get published, you can run docker-build-info with any optional argument. The generate tags will be used by docker-build and docker-push.
Running without arguments will result in something alike:
• From version 0.1.2 was parsed: MAJOR:0 MINOR:1 PATCH:2
• The production branch is master, so it has no sufix.
• It will building docker image: app-name:0.1.2
• The repos to publish are:
• registry.example.com
• gcr.io/my-id
• The tags are:
• group-name/app-name:0
• group-name/app-name:0.1
• group-name/app-name:0.1.2