Caprover: Feature Request: CDD Pre-Deploy Script

Created on 19 Feb 2018  路  6Comments  路  Source: caprover/caprover

I am using CDD to deploy a few node.js apps and am dealing with converting my Dockerfile to a captain-definition file. Because I have native Node.js modules in my app I have to use a custom Dockerfile. I've written a script to generate a captain-definition file from my custom Dockerfile but it would be awesome if I could automate running that script as a pre-deploy script. Maybe as an attribute in the captain-definition file.

Thoughts?

Most helpful comment

Yup. It's exactly that. 馃憤
I think i need to change it to not copy things into src folder. Anyways that will require some thinking to make sure that we cover as many cases as possible.

All 6 comments

There is an online tool which converts your Dockerfile to captain definition file:
https://githubsaturn.github.io/dockerfile-to-captain/

As for pre-deploy script, this is the purpose of Dockerfile.

  • If you want your script to run as a build step, simply add it to Dockerfile as a RUN command
  • If you want your script to run whenever your application restarts, add it as a CMD command.

I hope this answers your question. If there is a case that is not covered by the two cases I mentioned above, please let me know.

Because the script converts a Dockerfile into a captain-definition file I can't run the script inside of the Dockerfile but I still want to automate the process. The script is more or less a Node.js version of the online tool. It would be nice to automate the process so I don't have build bugs cause by me editing the Dockerfile and not running the script. If the script was some kind of pre-deploy hook to build a captain-definition on the fly I could edit the Dockerfile without worrying about the captain-definition file.

I see. A couple of points here:
1) captain-definition is the definition of build steps. Logically it doesn't make sense that definition at runtime makes changes to its own content. It's like, having a Dockerfile step that changes Dockerfile. This will be possible, but will be a very broken behavior.
2) pre-deploy logics should always sit in Dockerfile/captain-definition as they "are" pre-deploy scripts.
3) Your specific use case totally makes sense. That's why I am planning on changing captain-definition such that it can read directly from Dockerfile. It will be something like:

{
     schemaVersion : 1
     dockerFile : "Dockerfile.release"  # or "Dockerfile" or etc...
}

Re 3... sounds a bit like my suggestion here: https://github.com/githubsaturn/captainduckduck/issues/113 ;-)

Yup. It's exactly that. 馃憤
I think i need to change it to not copy things into src folder. Anyways that will require some thinking to make sure that we cover as many cases as possible.

That clearly the better solution. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rschaerer picture rschaerer  路  4Comments

polotto picture polotto  路  4Comments

drmrbrewer picture drmrbrewer  路  4Comments

gingerlime picture gingerlime  路  6Comments

hamza-younas94 picture hamza-younas94  路  4Comments