Esempio n. 1
0
    def get_working_directory(self):
        from jetee.runtime.configuration import project_configuration

        return os.path.join(
            project_configuration.get_primary_service().project.location,
            project_configuration.get_project_name()
        )
Esempio n. 2
0
    def get_container_volumes(self, service):
        from jetee.runtime.configuration import project_configuration

        volumes = service.volumes[:] if service.volumes else []
        if service.project:
            if service.project.media_location:
                media_directory = u'/var/jetee/%s/media/:%s' % (
                    project_configuration.get_project_name(), service.project.media_location.rstrip(u'/'))
                volumes.append(media_directory)
            if service.project.static_location:
                static_directory = u'/var/jetee/%s/static/:%s' % (
                    project_configuration.get_project_name(), service.project.static_location.rstrip(u'/'))
                volumes.append(static_directory)

            volumes += [self.get_web_process_socket_mapping(service)]
        return volumes
Esempio n. 3
0
 def get_config(self, parent):
     project = parent
     template = self.template.copy()
     template[u'git'][u'dest'] = os.path.join(project.location, project_configuration.get_project_name())
     template[u'git'][u'repo'] = project.cvs_repo_url
     template[u'git'][u'version'] = project.cvs_repo_branch
     return [template]
Esempio n. 4
0
 def get_config(self, parent):
     project = parent
     template = self.template.copy()
     template[u'django_manage'][u'app_path'] = os.path.join(project.location,
                                                            project_configuration.get_project_name())
     if project.get_env_variables():
         template[u'environment'] = project.get_env_variables()
     return [template]
Esempio n. 5
0
    def get_config(self, parent):
        service = parent
        from jetee.runtime.configuration import project_configuration

        config_name = u'.'.join([project_configuration.get_project_name(), service.container_name])
        config = {
            u'role': u'jdauphant.nginx',
            u'nginx_sites':
                {
                    config_name: [
                        u'listen 80',
                        u'server_name %s' % u' '.join(project_configuration.server_names),
                        u'proxy_connect_timeout 300s',
                        u'proxy_read_timeout 300s',
                        u'location / { '
                        u'proxy_connect_timeout 300s; '
                        u'proxy_read_timeout 300s;'
                        u'proxy_pass http://unix:%s;}' % self.get_proxy_pass_for_service(service),
                        self.get_media_config(service),
                        self.get_static_config(service)
                    ],
                    u'redirect_www': [
                        u'server_name "~^www\.(.*)$"',
                        u'return 301 $scheme://$1$request_uri'
                    ]
                }
            ,
            u'nginx_configs': {
                u'proxy': [
                    u'proxy_set_header X-Real-IP $remote_addr',
                    u'proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for',
                    u'proxy_set_header Host $http_host',
                    u'proxy_set_header X-NginX-Proxy true',
                ]
            }
        }

        return config
Esempio n. 6
0
 def container_full_name(self):
     """
     Container full name of the form {project_name.container_name}
     :return:
     """
     return u'-'.join([project_configuration.get_project_name(), self.container_name])
Esempio n. 7
0
    def get_proxy_pass_for_service(cls, service):
        from jetee.runtime.configuration import project_configuration

        return cls.service_upstream % (project_configuration.get_project_name(), service.container_name)
Esempio n. 8
0
    def get_media_config(self, service):
        from jetee.runtime.configuration import project_configuration

        if service.project:
            return u'location /media/ {alias  /var/jetee/%s/media/;}' % project_configuration.get_project_name()
        return u''
Esempio n. 9
0
 def get_config(self, parent):
     project = parent
     template = self.template.copy()
     template[u'pip'][u'chdir'] = os.path.join(project.location, project_configuration.get_project_name())
     template[u'pip'][u'requirements'] = project.requirements
     return [template]
Esempio n. 10
0
 def get_config(self, parent):
     project = parent
     template = self.template.copy()
     template[u'command'] = template[u'command'].format(project.cvs_repo_branch)
     template[u'args'][u'chdir'] = os.path.join(project.location, project_configuration.get_project_name())
     return [template]