2.4.2 • Published 6 years ago
docker-publish v2.4.2
docker-publish
npm script to build and push a Docker image.
Use this script to build and an image based on the version in your project's package.json
then push it to the Docker hub.
This is a derivative of docker-deploy npm package by djskinner.
Prerequisites
- Docker must be installed on the machine you are running docker-deploy on
- You have already configured access to the docker registry to be pushing to (by using
docker login
)
Install
npm i docker-publish --save-dev
Setup
Add a config.docker entry in your package.json
and simply specify the name of your docker image. For example:
"config": {
"docker": {
"imageName": "YOUR_DOCKERHUB_NAME/image-name"
}
},
Add docker-publish --- build|publishas an npm script in your package.json
With this granularity, you can set up separate targets in package.json to only build, or build and publish in one step.
"scripts": {
"docker-build": "docker-publish --- build",
"docker-publish": "docker-publish --- publish",
}
Usage
Assumes you have a Dockerfile
in the project root.
When you are ready to build and push a new image, simply run:
npm run docker-publish
If you want to just build an image, run:
npm run docker-build