All files builder.js

0% Statements 0/11
0% Branches 0/5
0% Functions 0/2
0% Lines 0/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74                                                                                                                                                   
'use strict';
 
// Modules
const _ = require('lodash');
 
// Supported versions
const supportedVersions = [
  '3',
  '3.11',
  '3.10',
  '3.9',
  '3.8',
  '3.7',
  '3.7',
  '3.6',
  '3.5',
  '2.7',
];
 
// Builder
module.exports = {
  name: 'python',
  config: {
    version: '3.7',
    supported: supportedVersions,
    patchesSupported: true,
    legacy: ['2.7'],
    command: 'tail -f /dev/null',
    moreHttpPorts: [],
    path: [
      '/var/www/.local/bin',
      '/usr/local/sbin',
      '/usr/local/bin',
      '/usr/sbin',
      '/usr/bin',
      '/sbin',
      '/bin',
    ],
    port: 80,
    ssl: false,
    sslExpose: false,
    volumes: [
      '/usr/local/bin',
      '/usr/local/share',
      '/usr/local/bundle',
    ],
  },
  parent: '_appserver',
  builder: (parent, config) => class LandoPython extends parent {
    constructor(id, options = {}) {
      options = _.merge({}, config, options);
      // Make sure our command is an array
      if (!_.isArray(options.command)) options.command = [options.command];
      options.command = options.command.join(' && ');
      // Build the nodez
      const python = {
        image: `python:${options.version}`,
        environment: {
          PATH: options.path.join(':'),
          PIP_USER: 'true',
          PYTHONUSERBASE: '/var/www/.local',
        },
        ports: (options.command !== 'tail -f /dev/null') ? [options.port] : [],
        volumes: options.volumes,
        command: `/bin/sh -c "${options.command}"`,
      };
      // Add port to "moreHttpsPorts"
      options.moreHttpPorts.push(options.port);
      // Send it downstream
      super(id, options, {services: _.set({}, options.name, python)});
    };
  },
};