docs: function createDockerFile() {
  
      const extraPkgs = [
          'nodejs',
          'nodejs-legacy',
          'git',
          'wget',
          'build-essential',
          // In case we'd need to fallback-to-build for some of the binary dependencies
          // and use node-gyp, we'd need python, so let's install it just in case.
          'python'
     ];
      const nodeVersion = pkg.deploy.node;
  
      if (nodeVersion === 'system') {
          // In case we're setting a specific node version we use nvm to install npm so we don't
          // need to install npm through the apt-get
          extraPkgs.push('npm');
      }
      // An array where we store custom-sourced extra packages
      // Each element has 'repo_url', 'release', 'pool' and 'packages' properties
      // 'packages' is an array of package names
      // 'repo_url' and 'pool' combinations are unique
      const customSourcePkgs = [];
      // An array of URIs of custom .deb packages to be installed
      const debPkgs = [];
  
      // set some defaults
      if (!pkg.deploy) {
          pkg.deploy = {};
      }
      if (!pkg.deploy.target) {
          pkg.deploy.target = 'debian';
      }
      if (!pkg.deploy.dependencies) {
          pkg.deploy.dependencies = {};
      }
      if (!pkg.deploy.dependencies._all) {
          pkg.deploy.dependencies._all = [];
      }
      if (!pkg.deploy.node) {
          pkg.deploy.node = 'system';
      }
  
      const npmVersion = pkg.deploy.npm;
      // set the deploy target
      // allow the user to specify the exact target to use, like "debian:sid"
      const baseImg = /^.+:.+$/.test(pkg.deploy.target) ? pkg.deploy.target : targets[pkg.deploy.target];
      let contents = `FROM ${baseImg}\n`;
  
      if (!baseImg || baseImg === '') {
          console.error('ERROR: You must specify a valid target!');
          console.error('ERROR: Check the deploy stanza in package.json and targets.yaml');
          process.exit(2);
      }
  
      // get any additional packages that need to be installed
      Object.keys(pkg.deploy.dependencies).forEach((sys) => {
          if (sys === '_all' || (sys === baseImg || (new RegExp(sys)).test(baseImg))) {
              pkg.deploy.dependencies[sys].forEach((pkg) => {
                  if (typeof pkg === 'string') {
                      extraPkgs.push(pkg);
                  } else if (typeof pkg === 'object') {
                      if (pkg.uri) {
                          debPkgs.push(pkg.uri);
                      } else if (!pkg.repo_url || !pkg.pool || !pkg.packages || !pkg.release) {
                          console.error(`ERROR: Incorrect dependency spec: ${JSON.stringify(pkg)}`);
                          process.exit(1);
                      } else {
                          customSourcePkgs.push(pkg);
                      }
                  } else {
                      console.error(`ERROR: Incorrect dependency spec: ${pkg}`);
                      process.exit(1);
                  }
              });
          }
      });
  
      if (customSourcePkgs.some((customSourcePkgSpec) => /^https/.test(customSourcePkgSpec.repo_url))) {
          extraPkgs.push('apt-transport-https');
      }
  
      contents += `RUN apt-get update && apt-get install -y ${extraPkgs.join(' ')} && rm -rf /var/lib/apt/lists/*\n`; /**/
  
      if (customSourcePkgs.length) {
          contents += `RUN echo > /etc/apt/sources.list && ${customSourcePkgs.map((customSourcePkgSpec) =>
              `echo deb "${customSourcePkgSpec.repo_url} ${customSourcePkgSpec.release} ${customSourcePkgSpec.pool}" >> /etc/apt/sources.list`).join(' && ')}\n`;
          contents += `RUN apt-get update && ${customSourcePkgs.map((customSourcePkgSpec) => `apt-get install -y --force-yes -t ${customSourcePkgSpec.release} ${customSourcePkgSpec.packages.join(' ')}`).join(' && ')} && rm -rf /var/lib/apt/lists/*\n`; /**/
      }
  
      if (debPkgs.length) {
          contents += `RUN ${debPkgs.map((uri) => `wget ${uri} -O package.deb && dpkg -i package.deb && rm package.deb`).join(' && ')}\n`;
      }
  
      let npmCommand = 'npm';
      if (nodeVersion !== 'system') {
          const nvmDownloadURI = 'https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh';
          contents += 'ENV NVM_DIR /usr/local/nvm\n';
          contents += `RUN wget -qO- ${nvmDownloadURI} | bash && . $NVM_DIR/nvm.sh && nvm install ${nodeVersion}\n`;
          npmCommand = `. $NVM_DIR/nvm.sh && nvm use ${nodeVersion} && npm`;
      }
  
      if (!opts.deploy) {
          contents += `RUN mkdir /opt/service\nADD . /opt/service\nWORKDIR /opt/service\nRUN ${npmCommand} install && npm dedupe\n`;
      }
  
      if (opts.uid !== 0 &&
              // In 'Docker for Mac' the mapping between users/groups
              // is done internally by docker, so we can run as root
              os.type() !== 'Darwin') {
          contents += `RUN groupadd -o -g ${opts.gid} -r rungroup && useradd -o -m -r -g rungroup -u ${opts.uid} runuser\nUSER runuser\nENV HOME=/home/runuser LINK=g++\n`;
      } else {
          contents += 'ENV HOME=/root/ LINK=g++\n';
      }
  
      let envCommand = 'ENV IN_DOCKER=1';
      if (pkg.deploy.env && Object.keys(pkg.deploy.env)) {
          Object.keys(pkg.deploy.env).forEach((envVar) => {
              envCommand += ` ${envVar}="${pkg.deploy.env[envVar]}"`;
          });
      }
      contents += `${envCommand}\n`;
  
      if (opts.deploy) {
          let beforeInstall = '';
          let afterInstall = '';
          if (npmVersion) {
              beforeInstall += `${npmCommand} install npm@${npmVersion} &&`;
              npmCommand = './node_modules/.bin/npm';
              afterInstall = '&& rm -rf ./node_modules/npm ./node_modules/.bin/npm';
          }
          let installOpts = ' --production ';
          if (pkg.deploy.install_opts) {
              installOpts += `${pkg.deploy.install_opts.join(' ')} `;
          }
          contents += `CMD ${beforeInstall} ${npmCommand} install${installOpts} ${afterInstall}`;
      } else if (opts.tests) {
          contents += `CMD ${npmCommand} test`;
      } else if (opts.coverage) {
          contents += `CMD ${npmCommand} run-script coverage`;
      } else {
          contents += `CMD ${npmCommand} start`;
      }
  
      return fs.writeFileAsync('Dockerfile', contents);
  
  }