Exemplo n.º 1
0
 def serviceGeneratorPriv(self, layerName, opt):
     service = docker.Service(
         name=layerName,
         image='127.0.0.1:5000/' + layerName,
         options=opt,
     )
     return service
Exemplo n.º 2
0
 def convertToService(self, tag='v1'):
     service = docker.Service(
         name=self.imageTag,
         image=self.serviceName + ':' + tag,
         options=self.opt,
     )
     self.setService(service)
Exemplo n.º 3
0
    def buildTraefic(self):
        #self._element.option=('network', ['efirmain'])

        #self._element.option=('command', ['--api', /entrypoint.sh traefik
        #                                  '--entrypoints=Name:http Address::80',
        #                                  '--defaultentrypoints=http',
        #                                  '--docker',
        #                                  '--docker.domain=docker-example.local',
        #                                  '--docker.watch'])
        #self._element.option=('volume', '/var/run/docker.sock:/var/run/docker.sock')
        #serviceName=self._element.myname+'_'+self._element.imageTag
        #serviceTag=self._element.imageTag
        #self._element.opt=('network', ['demo'])
        self._element.setService(
            service=docker.Service(name=self._element.imageTag,
                                   image=self._element.serviceTag,
                                   options=self._element.opt,
                                   args="--api.insecure=true \
            --providers.docker=true \
            --providers.docker.swarmMode=true \
            --providers.docker.watch=true \
            --providers.docker.swarmModeRefreshSeconds=15s \
            --providers.docker.exposedbydefault=false \
            '--providers.docker.defaultRule=Host('local.me')' \
            --entrypoints.web.address=:80 \
            --api.dashboard=true"))

        return self._element
Exemplo n.º 4
0
 def serviceGenerator(self, layerName, imageTag, opt):
     print(layerName)
     service = docker.Service(
         name=layerName,
         image=imageTag,
         options=opt,
     )
     return service
Exemplo n.º 5
0
    def fpm73_serv(self, seed='_seed', projectId='mybr'):

        service = docker.Service(
            name='phpfpm73' + seed,
            image='phpfpm73' + seed,
            options={
                #'publish': ['9003:9000'],
                'network': [projectId],
            },
        )
        return service
Exemplo n.º 6
0
 def pg_serv(self, seed='_seed', projectId='mybr'):
     service = docker.Service(
         name='pg_alldump' + seed,
         image='pg_alldump' + seed,
         options={
             'publish': ['54324:5432'],
             'network': [projectId],
             'env': [
                 'CLUSTER_USER=moscluster', 'CLUSTER_PASSWORD=Li2iR0wLa5',
                 'CLUSTER_DB=moscluster', 'POSTGRES_USER=postgres',
                 'POSTGRES_PASSWORD=BozCh128Mer', 'CUR_DUMP=dump.sql'
             ],
         },
     )
     return service
Exemplo n.º 7
0
    def nginx_serv(self, seed='_seed', projectId='mybr'):

        service = docker.Service(
            name='nginx' + seed,
            image='nginx' + seed,
            options={
                #'publish': ['81:81'],
                'volume': '/media:/media',
                'network': [projectId],
            },
        )
        #hosts=['[email protected]'],
        #roles=['web'],
        #registry=reg,
        #build_path='/home/ladmin/workspace_cpp/fabrica/nginx',
        return service
Exemplo n.º 8
0
    def buildNginx(self):
        self._element.opt = ('publish', ['81:80'])
        #self._element.net=NetworkManager(role=self._element._role, netname='demo', driver='local')
        #self._element.option=('network', ['demo'])
        firstVol = VolumeManager(role=self._element._role, source='vol1')
        firstVol.setDestination(destination='/usr/share/nginx/html')
        self._element.volumes = firstVol
        #self._element.option=('mount', ['type=volume,source=nfvol_1,destination=/usr/share/nginx/html,readonly=false'])
        dockererfile = self.dockerFactory.get_nginxCommonDictFile(
            layer=self._element.layerPath)
        self._element.add_dockerfile(dockererfile)
        self._element.setService(service=docker.Service(
            name=self._element.imageTag,
            image=self._element.serviceTag,
            options=self._element.opt,
        ))

        return self._element
Exemplo n.º 9
0
    def buildTraeficForEfir(self):
        self._element.opt = ('network', ['efirmain'])

        #self._element.option=('command', ['--api', /entrypoint.sh traefik
        #                                  '--entrypoints=Name:http Address::80',
        #                                  '--defaultentrypoints=http',
        #                                  '--docker',
        #                                  '--docker.domain=docker-example.local',
        #                                  '--docker.watch'])
        #self._element.option=('volume', '/var/run/docker.sock:/var/run/docker.sock')
        #serviceName=self._element.myname+'_'+self._element.imageTag
        #serviceTag=self._element.imageTag
        self._element.setService(service=docker.Service(
            name=self._element.serviceName,
            image=self._element.fullTag,
            options=self._element.opt,
            args='--api.insecure=true --api.dashboard=true'))
        #self._element.setService(self.generator.serviceGenerator(layerName=serviceName,
        #                                                         imageTag=serviceTag,
        #                                                         opt=self._element.option))
        return self._element
Exemplo n.º 10
0
    def buildFpm(self):
        #options={
        #        'publish': ['9003:9000']
        #    }

        #self._element.option=('publish', ['9003:9000'])
        #self._element.option=('network', ['demo'])
        #self._element.option=('label', [ 'com.docker.lb.backend_mode=task',
        #                               'com.docker.lb.hosts=demo.local'])
        firstVol = VolumeManager(role=self._element._role, source='vol1')
        firstVol.setDestination(destination='/usr/share/nginx/html')
        self._element.volumes = firstVol
        #self._element.option=('mount', ['type=volume,source=nfvol_1,destination=/usr/share/nginx/html,readonly=false'])
        dockererfile = self.dockerFactory.get_php73_fpmDictFile(
            layer=self._element.layerPath)
        self._element.add_dockerfile(dockererfile)
        #serviceName=self._element.myname+'_'+self._element.imageTag
        #serviceTag=os.path.join(self._element.registry, self._element.imageTag)
        self._element.setService(service=docker.Service(
            name=self._element.imageTag,
            image=self._element.serviceTag,
            options=self._element.opt,
        ))
        return self._element
Exemplo n.º 11
0
@author: ladmin
'''

from fabricio import docker, tasks
from projects import Efir, ItCluster
from _ast import arguments, In
from pickle import INST
#from compose.cli import command

web = tasks.DockerTasks(
    service=docker.Service(
        name='traefik',
        image='traefik',
        command='--api',
        options={
            #'publish': ['81:81'],
            #'volume': '/media:/media',
        },
    ),
    registry='127.0.0.1:5000',
    #roles=['web'],
    hosts=['[email protected]'],
    #account="ladmin"
)

DT = ItCluster()

if __name__ == '__main__':

    branch = 'rolesystem'
Exemplo n.º 12
0
                'docker swarm join-token --quiet manager',
                ignore_errors=True,
            )
            swarm_init.worker_join_command = (
                'docker swarm join --token {join_token} {host}:2377').format(
                    join_token=join_token, host=fab.env.host)
        else:
            fabricio.run(
                swarm_init.worker_join_command,
                ignore_errors=True,
            )

    with fab.settings(hosts=hosts):
        fab.execute(_swarm_init)


swarm_init.worker_join_command = None

nginx = tasks.DockerTasks(
    service=docker.Service(
        name='nginx',
        image='nginx:stable-alpine',
        options=dict(
            publish='8080:80',
            replicas=2,
            env='FOO=42',
        ),
    ),
    hosts=hosts,
)
Exemplo n.º 13
0
"""

import fabricio

from fabric import api as fab
from fabricio import tasks, docker
from fabricio.misc import AvailableVagrantHosts

hosts = AvailableVagrantHosts(guest_network_interface='eth1')

service = tasks.DockerTasks(
    service=docker.Service(
        name='my-service',
        image='nginx:stable-alpine',
        options=dict(
            # `docker service create` options
            replicas=2,
            env='FOO=42',
        ),
    ),
    hosts=hosts,

    # 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
)