@horloge/docker-image
v0.0.2
Published
[![npm](https://img.shields.io/npm/v/docker-image)](https://www.npmjs.com/package/docker-image)
Downloads
3
Readme
@horloge/docker-image
build docker images tools lib.
Install
npm i -D @horloge/docker-image
Usage
create config file on project root eg: horloge.config.js
module.exports = {
"docker-image":{
"dockerfileDir" : "./Dockerfile", //dockerfile path
"imagesName" : ({time,arg,version}) => { //docker image name
return `registry.docker.com/fe/helloworld-${arg}-${version}`
},
"save": { //save config
"imagesName" : ({time,arg,version}) => { //save docker image name
const { year, month, date } = time;
return `/helloworld-${year}${month}${date}-${arg}-${version}.tar`
},
"dockerDir" : "~", //save dockerfile path
},
"env": (arg) => { //docker build env
const arc = arg === 'test' ? "amd64" : "arm64";
return [
`--platform=linux/${arc}`,
`--build-arg ARC_TYPE=${arc}`,
]
}
}
}
create script in package.json
...
"scripts": {
"docker:build-test": "docker-image build --arg=test",
"docker:build-prod": "docker-image build --arg=prod",
"docker:build-test-save": "docker-image save --arg=test",
"docker:build-prod-save": "docker-image save --arg=prod",
"docker:push": "docker-image push --arg=test"
},
...
License
MIT, see the license file