示例#1
0
def build_prod(ctx):
    print("# Building!")
    Docker.build(cli,
        dockerfile='Dockerfile.dev',
        tag="{0}-dev".format(flow.get_branch_container_name())
    )

    print("Starting Development container")
    prod_api_url = 'homomorphic-encryption.appspot.com'
    prod_backend_url = 'homomorphic-encryption.appspot.com'

    container = cli.create_container(
        image="{0}-dev".format(flow.get_branch_container_name()),
        volumes=[
            '{0}:/app'.format(os.getcwd())
        ],
        host_config=cli.create_host_config(binds=[
            '{0}:/app'.format(os.getcwd())
        ]),
        environment={
            'CLIENT_API_ADDRESS': prod_api_url,
            'CLIENT_BACKEND_ADDRESS': prod_backend_url
        }
    )

    response = cli.start(container=container.get('Id'))

    Docker.execute(cli, container.get('Id'), "node --version")
    Docker.execute(cli, container.get('Id'), "npm --version")

    Docker.execute(cli, container.get('Id'), "npm install")
    Docker.execute(cli, container.get('Id'), "npm run postinstall")

    Docker.execute(cli, container.get('Id'), "npm run build:prod")

    cli.stop(container.get('Id'))
    cli.remove_container(container.get('Id'))

    print("# Building Production container!")
    Docker.build(cli, "Dockerfile.app", flow.get_build_container_name())
示例#2
0
def test(ctx):
    print("# Testing!")
    Docker.build(cli,
        dockerfile='Dockerfile.dev',
        tag="{0}-dev".format(flow.get_branch_container_name())
    )

    print("Starting Development container")
    container = cli.create_container(
        image="{0}-dev".format(flow.get_branch_container_name()),
        volumes=[
            '{0}:/app'.format(os.getcwd())
        ],
        host_config=cli.create_host_config(binds=[
            '{0}:/app'.format(os.getcwd())
        ])
    )
    response = cli.start(container=container.get('Id'))
    # print(response)

    Docker.execute(cli, container.get('Id'), "node --version")
    Docker.execute(cli, container.get('Id'), "npm --version")
    Docker.execute(cli, container.get('Id'), "npm install")
    Docker.execute(cli, container.get('Id'), "npm run postinstall")
    Docker.execute(cli, container.get('Id'), "npm run lint")
    Docker.execute(cli, container.get('Id'), "npm run test")

    cli.stop(container.get('Id'))
    cli.remove_container(container.get('Id'))