コード例 #1
0
ファイル: build.py プロジェクト: newrelic/shipyard
def build_application(interpreter
                     ,version
                     ,os_
                     ,port
                     ,application_name
                     ,launch
                     ,after_launch
                     ,before_launch
                     ,database_name
                     ,git_url
                     ,repository
                     ,client_url):
    """
    Build an application container based on a Dockerfile.
    """
    application_folder = crane_path('build/app/%s/%s' % (interpreter, application_name))
    if not os.path.exists(application_folder):
       os.makedirs(application_folder, 0755)

    save_in('%s/buildapp.sh' % application_folder
           ,render.application_install_script(interpreter, application_name, before_launch))
    save_in('%s/launch.sh' % application_folder
           ,render.application_launch_script(interpreter, launch, after_launch))
    save_in('%s/launcher.sh' % application_folder
           ,render.application_launcher_script(interpreter, launch, after_launch))
    # FIXME : split containers
    save_in('%s/sql_launcher.sh' % application_folder
           ,render.sql_launcher_script(database_name))

    tag = '%(os_)s/%(interpreter)s%(version)s/%(application_name)s' % locals()
    Dockerfile = render.application_Dockerfile(interpreter, version, os_, repository, application_name, git_url, port)
    return build(client_url, repository, Dockerfile, application_folder, locals(), tag)
コード例 #2
0
def build_application(interpreter, version, os_, port, application_name,
                      launch, after_launch, before_launch, database_name,
                      git_url, repository, client_url):
    """
    Build an application container based on a Dockerfile.
    """
    application_folder = crane_path('build/app/%s/%s' %
                                    (interpreter, application_name))
    if not os.path.exists(application_folder):
        os.makedirs(application_folder, 0755)

    save_in(
        '%s/buildapp.sh' % application_folder,
        render.application_install_script(interpreter, application_name,
                                          before_launch))
    save_in(
        '%s/launch.sh' % application_folder,
        render.application_launch_script(interpreter, launch, after_launch))
    save_in(
        '%s/launcher.sh' % application_folder,
        render.application_launcher_script(interpreter, launch, after_launch))
    # FIXME : split containers
    save_in('%s/sql_launcher.sh' % application_folder,
            render.sql_launcher_script(database_name))

    tag = '%(os_)s/%(interpreter)s%(version)s/%(application_name)s' % locals()
    Dockerfile = render.application_Dockerfile(interpreter, version, os_,
                                               repository, application_name,
                                               git_url, port)
    return build(client_url, repository, Dockerfile, application_folder,
                 locals(), tag)
コード例 #3
0
def build_os(os_, repository, client_url):
    """
    Build an os container based on a Dockerfile.
    """
    os_path = crane_path('build/os/%s' % os_)
    Dockerfile = render.os_Dockerfile(os_)
    return build(client_url, repository, Dockerfile, os_path, {'os': os_}, os_)
コード例 #4
0
ファイル: build.py プロジェクト: newrelic/shipyard
def build_os(os_, repository, client_url):
    """
    Build an os container based on a Dockerfile.
    """
    os_path = crane_path('build/os/%s' % os_)
    Dockerfile = render.os_Dockerfile(os_)
    return build(client_url, repository, Dockerfile, os_path, {'os' : os_} , os_)
コード例 #5
0
ファイル: inspect.py プロジェクト: newrelic/shipyard
def list_oses():
    oses_raw = os.listdir(crane_path('templates/os/'))
    oses_raw.remove('os.tpl')
    oses = []
    for os_ in oses_raw:
        if os_[0] != '.':
            oses.append((os_[:-4], os_[:-4]))
    return oses
コード例 #6
0
ファイル: inspect.py プロジェクト: newrelic/shipyard
def list_third_party_softwares():
    third_party_raw = os.listdir(crane_path('templates/third_party'))
    third_party_raw.remove('third_party.tpl')
    third_party_softwares = []
    for third_party in third_party_raw:
        if third_party.find('.') == -1:
            third_party_softwares.append((third_party, third_party))
    return third_party_softwares
コード例 #7
0
ファイル: inspect.py プロジェクト: newrelic/shipyard
def list_oses():
    oses_raw = os.listdir(crane_path('templates/os/'))
    oses_raw.remove('os.tpl')
    oses = []
    for os_ in oses_raw:
        if os_[0] != '.':
           oses.append((os_[:-4], os_[:-4]))
    return oses
コード例 #8
0
ファイル: inspect.py プロジェクト: newrelic/shipyard
def list_third_party_softwares():
    third_party_raw = os.listdir(crane_path('templates/third_party'))
    third_party_raw.remove('third_party.tpl')
    third_party_softwares = []
    for third_party in third_party_raw:
        if third_party.find('.') == -1:
           third_party_softwares.append((third_party, third_party))
    return third_party_softwares
コード例 #9
0
ファイル: inspect.py プロジェクト: newrelic/shipyard
def list_interpreters():
    interpreters_raw = os.listdir(crane_path('templates/interpreter/'))
    interpreters_raw.remove('interpreter.tpl')
    # Make python first in the list
    interpreters = [('python', 'python')]
    for interpreter in interpreters_raw:
        if interpreter != 'python':
            interpreters.append((interpreter, interpreter))
    return interpreters
コード例 #10
0
ファイル: inspect.py プロジェクト: newrelic/shipyard
def list_interpreters():
    interpreters_raw = os.listdir(crane_path('templates/interpreter/'))
    interpreters_raw.remove('interpreter.tpl')
    # Make python first in the list
    interpreters = [('python', 'python')]
    for interpreter in interpreters_raw:
	if interpreter != 'python':
           interpreters.append((interpreter, interpreter))
    return interpreters
コード例 #11
0
ファイル: build.py プロジェクト: newrelic/shipyard
def build_interpreter(interpreter, version, os_, repository, client_url):
    """
    Build a interpreter container based on a Dockerfile.
    """
    tag = '%s/%s' % (os_, interpreter + version)
    interpreter_path = crane_path('build/interpreter/%s' % interpreter)

    save_in(os.path.join(interpreter_path, 'install.sh'), render.interpreter_install_script(interpreter))
    Dockerfile = render.interpreter_Dockerfile(interpreter, version, os_, repository)
    return build(client_url, repository, Dockerfile, interpreter_path, locals(), tag)
コード例 #12
0
def build_interpreter(interpreter, version, os_, repository, client_url):
    """
    Build a interpreter container based on a Dockerfile.
    """
    tag = '%s/%s' % (os_, interpreter + version)
    interpreter_path = crane_path('build/interpreter/%s' % interpreter)

    save_in(os.path.join(interpreter_path, 'install.sh'),
            render.interpreter_install_script(interpreter))
    Dockerfile = render.interpreter_Dockerfile(interpreter, version, os_,
                                               repository)
    return build(client_url, repository, Dockerfile, interpreter_path,
                 locals(), tag)
コード例 #13
0
ファイル: build.py プロジェクト: newrelic/shipyard
def build_third(os_, software, root_password, user_password, repository, client_url):
    """
    Build a container that host a third party software like a database for exemple
    """
    third_party_folder = crane_path('build/third_party/%s' % software)
    if not os.path.exists(third_party_folder):
       os.makedirs(third_party_folder, 0755)
    
    save_in('%s/launch.sh' % third_party_folder
           ,render.third_party_launch_script(software, root_password, user_password))

    tag = '%(os_)s/%(software)s' % locals()
    Dockerfile = render.third_party_Dockerfile(os_, software, repository, client_url)
    return build(client_url, repository, Dockerfile, third_party_folder, locals(), tag)
コード例 #14
0
def build_third(os_, software, root_password, user_password, repository,
                client_url):
    """
    Build a container that host a third party software like a database for exemple
    """
    third_party_folder = crane_path('build/third_party/%s' % software)
    if not os.path.exists(third_party_folder):
        os.makedirs(third_party_folder, 0755)

    save_in(
        '%s/launch.sh' % third_party_folder,
        render.third_party_launch_script(software, root_password,
                                         user_password))

    tag = '%(os_)s/%(software)s' % locals()
    Dockerfile = render.third_party_Dockerfile(os_, software, repository,
                                               client_url)
    return build(client_url, repository, Dockerfile, third_party_folder,
                 locals(), tag)
コード例 #15
0
ファイル: render.py プロジェクト: newrelic/shipyard
from jinja2 import Environment, FileSystemLoader
from data import ports, manager
from base import crane_path
from os import path, mkdir
"""
In this file are all the function use to render the crane templates:
Dockerfiles, scripts, etc
"""

jinja_env = Environment(loader=FileSystemLoader(
    [crane_path('templates'), crane_path('build')]))

#   Dockerfiles -----------------------------------------------------------------------------------


def render_template__(template, **variables):
    """
    A simple helper to render the templates with the crane Environment.
    """
    return jinja_env.get_template(template).render(variables)


def os_Dockerfile(os):
    """
    Render the Dockerfile that install an os in a container.
    """
    return render_template__('os/%s.tpl' % os, **locals())


def interpreter_Dockerfile(interpreter, version, os, repository):
    """
コード例 #16
0
ファイル: render.py プロジェクト: newrelic/shipyard
from jinja2 import Environment, FileSystemLoader
from data import ports, manager
from base import crane_path
from os import path, mkdir

"""
In this file are all the function use to render the crane templates:
Dockerfiles, scripts, etc
"""

jinja_env = Environment(loader=FileSystemLoader([crane_path('templates'), crane_path('build')]))

#   Dockerfiles -----------------------------------------------------------------------------------

def render_template__(template, **variables):
    """
    A simple helper to render the templates with the crane Environment.
    """
    return jinja_env.get_template(template).render(variables)

def os_Dockerfile(os):
    """
    Render the Dockerfile that install an os in a container.
    """
    return render_template__('os/%s.tpl' % os, **locals())

def interpreter_Dockerfile(interpreter, version, os, repository):
    """
    Render the Dockerfile that install an interpreter version in a container.
    """
    return render_template__('interpreter/%s/%s.tpl' % (interpreter, interpreter), **locals())