Example #1
0
    def buildPostgresWithDatabase(self):

        #self._element.option=('env',  ['CLUSTER_USER=moscluster',
        #                       'CLUSTER_PASSWORD=Li2iR0wLa5',
        #                       'CLUSTER_DB=moscluster',
        #                       'POSTGRES_USER=postgres',
        #                       'POSTGRES_PASSWORD=BozCh128Mer',
        #                       'CUR_DUMP=mk.sql' ])
        self._element.opt = ('env', ['PGDATA=/var/lib/postgresql-static/data'])
        self._element.opt = ('network', ['demo_local'])
        #self._element.option=('mount', ['type=volume,source=intervol,destination=/var/lib/postgresql/data,readonly=false'])
        self._element.setService(service=docker.Container(
            name=self._element.imageTag,
            image=self._element.serviceTag,
            options=self._element.opt,
        ))
        #self._element.options=opt
        pgDockerfile = self.dockerFactory.get_PostgresProvision(
            layer=self._element.layerPath,
            dbname='moscluster',
            dbuser='******',
            dbpass='******')
        self._element.add_dockerfile(pgDockerfile)

        #res=subprocess.run('/usr/bin/pg_dump -Fc --host=10.32.201.213 --username=moscluster  --schema-only --file=./tmp/mk.sql --dbname=moscluster', shell=True)
        #res=subprocess.Popen(['ls', '-la'])

        return self._element
Example #2
0
 def webbuild(self, reg='127.0.0.1:5000'):
     Webprod = tasks.ImageBuildDockerTasks(
         service=docker.Container(
             name='base',
             image='app',
         ),
         roles=['web'],
         registry=reg,
         build_path='/home/ladmin/workspace_cpp/fabrica/nginx',
     )
     return Webprod
Example #3
0
    def makePostgres(self):
        self._element.opt = ('network', ['demo'])
        self._element.opt = ('mount', [
            'type=volume,source=intervol,destination=/var/lib/postgresql/data,readonly=false'
        ])
        self._element.setService(service=docker.Container(
            name=self._element.imageTag,
            image=self._element.serviceTag,
            options=self._element.opt,
        ))

        return self._element
Example #4
0
    def phpfpm(self, reg='127.0.0.1:5000'):
        PhpFpm = tasks.ImageBuildDockerTasks(
            service=docker.Container(
                name='phpfpm',
                image='fpm',
                options={
                    'publish': ['9000:9000'],
                    'link': ['fpm'],
                },
            ),
            registry=reg,
            build_path='/home/ladmin/workspace_cpp/fabrica/php-fpm',
            roles=['phpfpm'],
        )

        return PhpFpm
Example #5
0
 def web(self, reg='127.0.0.1:5000'):
     Web = tasks.DockerTasks(
         service=docker.Container(
             name='web',
             image='127.0.0.1:5000/app',
             options={
                 'publish': ['81:81'],
                 'volume': '/media:/media',
             },
         ),
         registry=reg,
         roles=['web'],
         #hosts=['[email protected]'],
         #account="ladmin"
     )
     return Web
Example #6
0
@fabricio.infrastructure(color=colors.red)
def vagrant():
    fab.env.update(roledefs={
        'web': AvailableVagrantHosts(),
    }, )


@fabricio.infrastructure
def localhost(force_local=False):
    if utils.strtobool(force_local):
        # replace fabricio.run by fabricio.local to run all commands locally
        fabricio.run = functools.partial(fabricio.local, capture=True)

        # uncomment row below to skip file uploading (e.g. docker-compose.yml)
        # fab.put = lambda *args, **kwargs: None

    fab.env.update(roledefs={
        'web': ['localhost'],
    }, )


nginx = tasks.DockerTasks(
    service=docker.Container(
        name='nginx',
        image='nginx:stable-alpine',
        options=dict(publish='80:80', ),
    ),
    roles=['web'],
    destroy_command=True,
)
Example #7
0
from fabricio import tasks, docker
from fabricio.misc import AvailableVagrantHosts

my_nginx = tasks.ImageBuildDockerTasks(
    service=docker.Container(
        name='my_nginx',
        image='my_nginx',
        options=dict(publish='80:80', ),
    ),
    hosts=AvailableVagrantHosts(),
    registry='localhost:5000',
    ssh_tunnel_port=5000,
)
from fabricio import tasks, docker
from fabricio.misc import AvailableVagrantHosts

all_hosts = AvailableVagrantHosts(guest_network_interface='eth1')
# all_hosts = ['127.0.0.1'] * 3

custom = tasks.ImageBuildDockerTasks(
    service=docker.Container(
        name='custom',
        image='nginx',
        options={
            # 'publish': '80:80',
        },
    ),
    hosts=all_hosts[:1],
    account='renskiy',  # !! change this to your hub.docker.com account name !!
)
Example #9
0
        # replace fabricio.run by fabricio.local to run all commands locally
        fabricio.run = functools.partial(fabricio.local, capture=True)

        # uncomment row below to skip file uploading (e.g. docker-compose.yml)
        # fab.put = lambda *args, **kwargs: None

    fab.env.update(roledefs={
        'web': ['localhost'],
    }, )


app = tasks.DockerTasks(
    service=docker.Container(
        name='app',
        image='nginx:stable-alpine',
        options={
            # `docker run` options
            'env': 'FOO=42',
        },
    ),
    roles=['web'],

    # rollback_command=True,  # show `rollback` command in the list
    # migrate_commands=True,  # show `migrate` and `migrate-back` commands in the list
    # backup_commands=True,  # show `backup` and `restore` commands in the list
    # pull_command=True,  # show `pull` command in the list
    # update_command=True,  # show `update` command in the list
    # revert_command=True,  # show `revert` command in the list
    # destroy_command=True,  # show `destroy` command in the list
)
from fabricio import tasks, docker
from fabricio.misc import AvailableVagrantHosts

all_hosts = AvailableVagrantHosts(guest_network_interface='eth1')
# all_hosts = ['127.0.0.1'] * 3

nginx = tasks.DockerTasks(
    service=docker.Container(
        name='nginx',
        image='nginx:stable-alpine',
        options={
            # 'publish': '80:80',
        },
    ),
    hosts=all_hosts[:1],
    # account='renskiy',  # !! change this to your hub.docker.com account name !!
    # registry='localhost:5000',
    # ssh_tunnel_port=5000,
    # migrate_commands=True,
    # backup_commands=True,
    # pull_command=True,
    # update_command=True,
    # revert_command=True,
)
Example #11
0
from fabricio import tasks, docker
from fabricio.misc import AvailableVagrantHosts

nginx = tasks.DockerTasks(
    container=docker.Container(
        name='nginx',
        image='nginx:stable',
        options=dict(ports='80:80', ),
    ),
    hosts=AvailableVagrantHosts(),
)
Example #12
0
from fabricio import docker, tasks

__all__ = []  # hack

service1 = tasks.DockerTasks(
    service=docker.Container(
        name='service1',
        image='nginx:stable-alpine',
    ),
    hosts=[],
)

service2 = tasks.DockerTasks(
    service=docker.Container(
        name='service2',
        image='nginx:stable-alpine',
    ),
    hosts=[],
)
Example #13
0
from fabric import api
from fabricio import docker, tasks

host = '195.201.27.44'


@api.hosts(f'root@{host}')
@api.task
def create_docker_network():
    api.run(
        'docker network create --subnet 172.20.0.0/24 --gateway 172.20.0.1 teeworlds',
    )


teeworlds = tasks.ImageBuildDockerTasks(
    service=docker.Container(
        name='teeworlds',
        image='teeworlds',
        options=dict(
            network='teeworlds',
            ip='172.20.0.2',
            publish='8303:8303/udp',
        ),
    ),
    ssh_tunnel='5000:5000',
    registry='localhost:5000',
    hosts=[f'root@{host}'],
    build_path='teeworlds',
)