https://github.com/hellivan/docker-snapshot-image
CLI utiltiy for creating docker snapshot images from an existing Node.JS project
https://github.com/hellivan/docker-snapshot-image
ci docker docker-images docker-snapshot-images git npm package-json snapshot
Last synced: 3 months ago
JSON representation
CLI utiltiy for creating docker snapshot images from an existing Node.JS project
- Host: GitHub
- URL: https://github.com/hellivan/docker-snapshot-image
- Owner: hellivan
- License: mit
- Created: 2016-12-12T23:22:58.000Z (over 9 years ago)
- Default Branch: develop
- Last Pushed: 2023-11-11T01:49:28.000Z (over 2 years ago)
- Last Synced: 2025-08-09T04:45:35.938Z (10 months ago)
- Topics: ci, docker, docker-images, docker-snapshot-images, git, npm, package-json, snapshot
- Language: TypeScript
- Homepage:
- Size: 411 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# docker-snapshot-image
[](https://circleci.com/gh/hellivan/docker-snapshot-image)
[](https://codecov.io/gh/hellivan/docker-snapshot-image)
[](LICENSE)
[](https://github.com/semantic-release/semantic-release)
[](https://renovatebot.com/)
[](https://www.npmjs.com/package/docker-snapshot-image)
[](https://www.npmjs.com/package/docker-snapshot-image)
Command line utiltiy that allows to easily create docker snapshot-images from an exising node.js project. The resulting images by default will be tagged as follows: `{project-name}:{project-version}-{git-short-hash}`
## Prerequisites
Since this application makes use of git and docker, the two applications must be preinstalled on the system. Additionally, the directory in which the application is executed, must contain a valid **package.json** and **Dockerfile**.
## Usage
You can use this utilty by installing it globally and executing it in your project's root directory:
```
npm i -g docker-snapshot-image
cd /path/to/your/project
docker-snapshot-image
```
For a project with the following package.json:
```
{
"name": "my-project",
"version": "1.1.0",
...
}
```
executing the command would result in an image with a tag of the follwoing shape `my-project:1.1.0-f941929`. The hash appended to the version of the images always matches the short-version of the project's current git commit.
For advanced usage, command line flags can be used to change the default behavoir of the application:
| Flag | Description |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --fixed-tag | Additionally tag the image with the specified tag (could be used to always add _latest_ tag to image) |
| --auto-tag-format | Format of the automatically generated tag.
Available variable are `{branch-name}`, `{pkg-version}` and `{commit-hash}`.
The default format is `{pkg-version}-{commit-hash}` |
| --image-name | Use the specified custom name for the image |
| --no-auto | Do not create the image with the automatic snapshot-tag specified in auto-tag-format |
However, for a fully detailed description of all flags that can be used, see the application's usage information (`docker-snapshot-image --help`).
## NOTES
For branchname determination we are generally using the `git rev-parse --abbrev-ref HEAD` command. However, since some CI environments (e.g. Jenkins)
are not actually checking out the actual branch but rather the pushed commit itself, we are optionally checking for environment varable `BRANCH_NAME`
before starting branchname determination using `git rev-parse`.
## Environment variables
The application reads the following environment variables:
- `CONTAINER_IMAGE_REGISTRY_PASS`
- `CONTAINER_IMAGE_REGISTRY_USER`
- `CONTAINER_IMAGE_REGISTRY_REPO`