1

I'm currently working on getting a good workflow going on, from development to a kubernetes deployment on cloud platform.

I'm pretty comfortable with various docker commands, but rewriting long commands each time is getting painful.

For example, for deploying docker images to google cloud I need to tag and push them to google gcloud.

docker tag my-image gcr.io/my-project/my-image:test
gcloud docker -- push gcr.io/my-project/my-image 

This would obviously be quite painful to write out everyday, so for conveinience I could put these into package json and run them with something like npm run docker-image-release.

The question I have is - is mixing package.json and docker/deployment stuff frowned upon? Or is this a perfectly reasonable project structure?

If it is a bad idea - what's the best way to conveniently remember commands I'm using a lot?

  • 1
    What about Shell Scripts? When I'm working with dockers, I usually have 3 : DockerBuild.sh, Dockerrun.sh (which stops and removes running containers) and Dockerpublish.sh. Moreover, the scripts are stored in the scm alongside with the src, so that I can reuse them for CI and CD. – Laiv Feb 15 '18 at 6:36
  • @Laiv Thanks for the message. I actually have been doing this as well - but I generally think that bash scripts are a little messy in my code. – dwjohnston Feb 15 '18 at 8:25
  • Most people have a scripts folder for just this purpose. – sylvanaar Feb 15 '18 at 15:51
4

If it's an entirely private Node module, and it works for you, then go ahead.

However, I'd say the "correct" answer is No because if you published the module (even to a private corporate npm repo), you're now leaking deployment stuff into the app's configuration. Now you've given anyone that installs your project a way to mess with your build process.

Also, it's just bad separation of concerns. npm is a package manager, not a build tool.

  • Thanks for the answer. I've updated my question to ask if it's not a good way to go - then what is? Shell scripts? – dwjohnston Feb 15 '18 at 8:28
  • Shell scripts or whatever that works for you. IMO the building, the deploying and the delivering should be processes totally untied from each other. So that you can orchestrate these processes at will. Just laying (at least) on a very basic layer, the OS. If you don't like shell scripts, I would say Make files, but Make files require us to have certain dev tools that in certain environments could be forbidden. – Laiv Feb 15 '18 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.