Captain Definition File - GreyDelamar/captainduckduck GitHub Wiki

Captain Definition File

One of the key components of CaptainDuckDuck is the captain-definition file that sits at the root of your project. In case of Node.JS app, it sits next package.json, or next to index.php in case of PHP, or requirements.txt for Python app. It's a simple JSON like below:

{
  "schemaVersion" : 1 ,
  "templateId" :"node/8.7.0"
}

schemaVersion is always 1 and templateId is the piece which defines the what sort of base you need in order to run your app. It is in LANGUAGE/VERSION format. LANGUAGE can be one of these: node, php, python. See supported versions.

Note: that although the current version of CaptainDuckDuck comes with 3 most popular web app languages: Node.JS, PHP and Python (Django). It gives you the advanced option of defining your own Dockerfile. For example, the two captain-definition files below generate the exact same result.

Simple version

 {
  "schemaVersion" :1 ,
  "templateId" :"node/8.7.0"
 }

Advanced Version

 {
  "schemaVersion" :1 ,
  "dockerfileLines" : [
                        "FROM node:8.7.0-alpine",
                        "RUN mkdir -p /usr/src/app",
                        "WORKDIR /usr/src/app",
                        "COPY ./src/package.json /usr/src/app/",
                        "RUN npm install && npm cache clean --force",
                        "COPY ./src /usr/src/app",
                        "ENV NODE_ENV production",
                        "ENV PORT 80",
                        "EXPOSE 80",
                        "CMD [ \"npm\", \"start\" ]"
                    ]
 }

Even if you don't know anything about Docker, you can get an idea what this does.

IMPORANT NOTE: Captain generates a dockerfile and puts it besides a directory named src where your source code sits. So if in your normal dockerfile, you have COPY ./somefile /usr/app, you will have to change it to COPY ./src/somefile /usr/app otherwise deploy would fail.

Using this approach you can deploy Ruby, Java, Scala, literally everything! As Captain becomes more mature, more and more languages will be added to the built-in template, so you don't have to create the dockerfile manually like above. If you need more details on dockerfile, please see:

https://docs.docker.com/engine/reference/builder/ and https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/