Skip to content

Instantly share code, notes, and snippets.

@cyxou
Last active October 1, 2016 09:17
Show Gist options
  • Save cyxou/713993cc42db2e42db8d9be8b01f9450 to your computer and use it in GitHub Desktop.
Save cyxou/713993cc42db2e42db8d9be8b01f9450 to your computer and use it in GitHub Desktop.
Docker tasks in npm build scripts
{
"config": {
"docker": {
"reg": "XXXXXXXXXXXX.dkr.ecr.eu-west-1.amazonaws.com",
"ns": "mynamespace"
}
},
"scripts": {
"//0": "______________________ UTILITIES _______________________________________",
"dumpconf": "env | grep npm_ | sort | uniq",
"confirm": "printf '\\033[0;31mAre you sure you wanna do this (y/n)? \\033[0m'; read REPLY; if [ \"$REPLY\" != \"y\" ]; then exit 1; fi;",
"//1": "______________________ BUILD DOCKER CONTAINER __________________________",
"docker:build": "docker build -t $npm_package_config_docker_ns/$npm_package_name:$npm_package_version .",
"docker:tag": "docker tag $npm_package_config_docker_ns/$npm_package_name:$npm_package_version $npm_package_config_docker_reg/$npm_package_name:$npm_package_version",
"docker:push": "docker push $npm_package_config_docker_reg/$npm_package_name:$npm_package_version",
"docker:run": "docker run -it -p 8080:80 --rm --env-file ./.env --name $npm_package_name $npm_package_config_docker_ns/$npm_package_name:$npm_package_version",
"docker:all": "npm run docker:build -s && npm run docker:tag -s && npm run docker:push -s",
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment