def setup_remotely(): """Set up the container on a remote server - uses nested fabgis calls. Use this task when you want to set up the container on a remote server. It will log in to the server and then run fabric in a shell session so that all requests appear to originate locally. This is a work around for current inability to tunnel cleanly into the docker container from outside the docker's host. """ with cd(work_dir): run('echo "fabgis" > requirements.txt') setup_venv(work_dir) container_id = current_docker_container() if container_id is None: container_id = create_docker_container(image='fabgis/sshd') port_mappings = get_docker_port_mappings(container_id) ssh_port = port_mappings[22] run('wget -O fabfile.py https://github.com/AIFDR/inasafe-doc' '/raw/master/fabfile.py') require.directory('scripts') run('wget -O scripts/inasafe-doc.conf.templ https://github' '.com/AIFDR/inasafe-doc/raw/master/scripts/inasafe-doc.conf.templ') run('wget -O scripts/inasafe.org.mod_proxy.conf.templ https://github' '.com/AIFDR/inasafe-doc/raw/master/scripts/inasafe.org.mod_proxy.' 'conf.templ') run('venv/bin/fab -H root@%s:%i setup_web_user' % (env.host, ssh_port)) run('venv/bin/fab -H web@%s:%i setup_docs_web_site' % (env.host, ssh_port))
def setup_docs_web_proxy(): """Set up a mod proxy based vhost to forward web traffic to internal host. If container_id is none, it will also install docker and set up the entire documentation web site inside that docker container. """ require.directory(work_dir) with cd(work_dir): run('echo "fabgis" > requirements.txt') setup_venv(work_dir) container_id_file = 'fabgis.container.id' if not exists(container_id_file): setup_docker() setup_remotely() container_id = current_docker_container() port_mappings = get_docker_port_mappings(container_id) http_port = port_mappings[80] fabtools.require.deb.package('apache2') sudo('a2enmod proxy proxy_http') context = { 'internal_host': env.host, 'internal_port': http_port, 'server_name': 'inasafe.org' } apache_conf_template = 'inasafe.org.mod_proxy.conf.templ' apache_path = '/etc/apache2/sites-available' # Clone and replace tokens in apache conf local_dir = os.path.dirname(__file__) local_file = os.path.abspath(os.path.join( local_dir, 'scripts', apache_conf_template)) fastprint(green('Using %s for template' % local_file)) destination = '%s/inasafe.org.conf' % apache_path upload_template( local_file, destination, context=context, use_sudo=True) require.apache.enable('inasafe.org') restart('apache2')
def update_venv(code_path): """Update the virtual environment to ensure it has node etc. installed. :param code_path: Directory in which project is located. :type code_path: str e.g.:: fab -H localhost update_venv:/home/timlinux/dev/python/osm-reporter """ setup_venv(code_path, requirements_file='requirements.txt')
def setup_docs_web_proxy(): """Set up a mod proxy based vhost to forward web traffic to internal host. If container_id is none, it will also install docker and set up the entire documentation web site inside that docker container. """ require.directory(work_dir) with cd(work_dir): run('echo "fabgis" > requirements.txt') setup_venv(work_dir) container_id_file = 'fabgis.container.id' if not exists(container_id_file): setup_docker() setup_remotely() container_id = current_docker_container() port_mappings = get_docker_port_mappings(container_id) http_port = port_mappings[80] fabtools.require.deb.package('apache2') sudo('a2enmod proxy proxy_http') context = { 'internal_host': env.host, 'internal_port': http_port, 'server_name': 'inasafe.org' } apache_conf_template = 'inasafe.org.mod_proxy.conf.templ' apache_path = '/etc/apache2/sites-available' # Clone and replace tokens in apache conf local_dir = os.path.dirname(__file__) local_file = os.path.abspath( os.path.join(local_dir, 'scripts', apache_conf_template)) fastprint(green('Using %s for template' % local_file)) destination = '%s/inasafe.org.conf' % apache_path upload_template(local_file, destination, context=context, use_sudo=True) require.apache.enable('inasafe.org') restart('apache2')
def setup_venv(): """Initialise or update the virtual environmnet. To run e.g.:: fab -H 188.40.123.80:8697 remote setup_venv or if you have configured env.hosts, simply fab remote setup_venv """ virtualenv.setup_venv(env.code_path, requirements_file='requirements.txt') # Run again to check all is up to date with cd(env.code_path): run('venv/bin/pip install -r requirements.txt')
def update_venv(code_path): """Update the virtual environment to ensure it has node etc. installed. :param code_path: Directory in which project is located. :type code_path: str e.g.:: fab -H localhost update_venv:/home/timlinux/dev/python/projecta """ setup_venv(code_path, requirements_file='REQUIREMENTS.txt') #yuglify needed by django-compress needs to have node installed which # is provided by virtual-node in the REQUIREMENTS file above, # but we still need to install yuglify manually since we cant add it # using REQUIREMENTS. # See also https://github.com/elbaschid/virtual-node # for more info on how virtualnode works with cd(code_path): run('venv/bin/npm -g install yuglify') build_pil(code_path)
def setup_remotely(): """Set up the container on a remote server - uses nested fabgis calls. Use this task when you want to set up the container on a remote server. It will log in to the server and then run fabric in a shell session so that all requests appear to originate locally. This is a work around for current inability to tunnel cleanly into the docker container from outside the docker's host. """ with cd(work_dir): run('echo "fabgis" > requirements.txt') setup_venv(work_dir) container_id = current_docker_container() if container_id is None: container_id = create_docker_container(image='fabgis/sshd') port_mappings = get_docker_port_mappings(container_id) ssh_port = port_mappings[22] run('wget -O fabfile.py https://github.com/AIFDR/inasafe-doc' '/raw/master/fabfile.py') require.directory('scripts') run( 'wget -O scripts/inasafe-doc.conf.templ https://github' '.com/AIFDR/inasafe-doc/raw/master/scripts/inasafe-doc.conf.templ') run( 'wget -O scripts/inasafe.org.mod_proxy.conf.templ https://github' '.com/AIFDR/inasafe-doc/raw/master/scripts/inasafe.org.mod_proxy.' 'conf.templ') run('venv/bin/fab -H root@%s:%i setup_web_user' % ( env.host, ssh_port)) run('venv/bin/fab -H web@%s:%i setup_docs_web_site' % ( env.host, ssh_port))