title: How to convert a YAML file to Dockerfile
body: <p>Before describing the problem I need to give an overview of what I am doing:
  I have to pass a JSON file containing base images and dependencies and generate a YAML file. I am able to generate the YAML file but the next step is to use the generated YAML file to make a docker file.</p>
  
  <p>My idea:
  Basically, dockerhub has all programs like pyhton3, java etc installed on library/docker and many other folders like that. </p>
  
  <p>JSON file <strong>sample.json</strong> :</p>
  
  <pre><code>{
      "base_image" : "ubuntu",
      "dependency" : ["dependency1", "dependency2"]
  }
  </code></pre>
  
  <p>My <strong>handler.js</strong> function for validating the json file (Here event is the JSON file) :</p>
  
  <pre><code>'use strict';
  //const fs = require("fs")
  module.exports.validate = (event, context, callback) =&gt; {
  
  var JSONObject = JSON.parse(event.body);
  var base_image = JSONObject.base_image;
  var dependency = JSONObject.dependency;
  if(base_image == "" || dependency == "")
  {
    const response = {
      statusCode: 400,
      body: JSON.stringify({
      message: "false"
    })
    };
    callback(null, response);
  }
  else{
    const response = {
      statusCode: 200,
      body: JSON.stringify({
      message: true
    }),
    };
  
  callback(null, response);
  }
  
  };
  </code></pre>
  
  <p>I have a YAML file <strong>sample.yml</strong> like :</p>
  
  <pre><code>---
    base_image : "ubuntu"
    dependency:
      - "dependency1"
      - "dependency2"
  </code></pre>
  
  <p>And I have to generate a docker file out of this. Is this possible?
  If so how?</p>
  
  <p>Plese note this is a POC and I am trying to make a serverless microservice that generates a dockerfile out of the json file given as input which contains base_image and dependencies.</p>
  
  <p>Thanks in advance :)</p>
  
  <p>EDIT1:
  I have already converted the JSON to YAML using npm install -g json2yaml. Now I have to use the YAML to autogenerate dockerfile.</p>