Installing Press App - Frappe Cloud Local Setup

You can comment out this line in team.py

These changes were meant for internal purposes and weren’t removed before we made it open-source.

Any one help me on this?

Traceback (most recent call last):
File “apps/frappe/frappe/app.py”, line 66, in application
response = frappe.api.handle()
File “apps/frappe/frappe/api.py”, line 54, in handle
return frappe.handler.handle()
File “apps/frappe/frappe/handler.py”, line 45, in handle
data = execute_cmd(cmd)
File “apps/frappe/frappe/handler.py”, line 83, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “apps/frappe/frappe/init.py”, line 1607, in call
return fn(*args, **newargs)
File “apps/frappe/frappe/desk/form/save.py”, line 26, in savedocs
doc.save()
File “apps/frappe/frappe/model/document.py”, line 305, in save
return self._save(*args, **kwargs)
File “apps/frappe/frappe/model/document.py”, line 327, in _save
return self.insert()
File “apps/frappe/frappe/model/document.py”, line 276, in insert
self.run_method(“after_insert”)
File “apps/frappe/frappe/model/document.py”, line 914, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “apps/frappe/frappe/model/document.py”, line 1264, in composer
return composed(self, method, *args, **kwargs)
File “apps/frappe/frappe/model/document.py”, line 1246, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “apps/frappe/frappe/model/document.py”, line 911, in fn
return method_object(*args, **kwargs)
File “apps/press/press/press/doctype/tls_certificate/tls_certificate.py”, line 29, in after_insert
self.obtain_certificate()
File “apps/press/press/press/doctype/tls_certificate/tls_certificate.py”, line 36, in obtain_certificate
get_current_team(),
File “apps/press/press/utils/init.py”, line 44, in get_current_team
frappe.throw(“Invalid Team”, frappe.PermissionError)
File “apps/frappe/frappe/init.py”, line 525, in throw
msgprint(
File “apps/frappe/frappe/init.py”, line 493, in msgprint
_raise_exception()
File “apps/frappe/frappe/init.py”, line 442, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.PermissionError: Invalid Team

You can setup a TLS Certificate with wild card checked.
Go the TLS Certificate List and create one.

PS: You may run into certbot issues, to resolve this make sure you

  1. Uninstall all existing certbot installed with apt

  2. use snap to install certbot and all its dependencies including the route 53 plugin and not apt or pip

Follow the instructions here to install

@oderao I followed your suggestion and installed certbot and the route53 plugin using snap but the TLS certificate request fails in Root Domain setup. The root domain is portal.mydomain.com and it is pointed to the instance that hosts press. If I try to obtain the certificate manually I get index out of range. The Frappe instance is running in development mode hence the url is portal.mydomain.com:8000. Could it be a problem?

This is the full traceback to the index error:

Form/TLS Certificate/*.portal.mydomain.com

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 66, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 45, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1608, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/handler.py", line 304, in run_doc_method
    response = doc.run_method(method)
  File "apps/frappe/frappe/model/document.py", line 914, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1264, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1246, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 911, in fn
    return method_object(*args, **kwargs)
  File "apps/press/press/press/doctype/tls_certificate/tls_certificate.py", line 36, in obtain_certificate
    get_current_team(),
  File "apps/press/press/utils/__init__.py", line 60, in get_current_team
    team = team_dict[0].name
IndexError: list index out of range

Also, frappe 14 seems to have major and significant changes not reflected in the press deployment documentation. This makes it extremely difficult to follow and especially with the way the domain settings is described.

Frappe Press is largely WIP so its very buggy right now

When the root domain setup fails , What is the response? you can check the error logs

Usually it logs all failed attempts in the Error Log

Also have you added a TLS Certificate for the wildcard domain in your case it should be *.mydomain.com
I suggest you do this first before adding a certificate for root domain

The index error you are getting has to do with teams
you have to add a team, go to Teams List and add a default team

@oderao Here is the error logged for the failed TLS Certificate issuance

Exception:
Traceback with variables (most recent call last):
  File "apps/press/press/press/doctype/tls_certificate/tls_certificate.py", line 55, in _obtain_certificate
    ) = ca.obtain(
      self = <TLSCertificate: *.portal.mydomain.com>
      settings = <PressSettings: Press Settings>
      ca = <press.press.doctype.tls_certificate.tls_certificate.LetsEncrypt object at 0x7fc285fca170>
  File "apps/press/press/press/doctype/tls_certificate/tls_certificate.py", line 177, in obtain
    self._obtain()
      self = <press.press.doctype.tls_certificate.tls_certificate.LetsEncrypt object at 0x7fc285fca170>
      domain = 'portal.mydomain.com'
      rsa_key_size = ********
      wildcard = 1
  File "apps/press/press/press/doctype/tls_certificate/tls_certificate.py", line 209, in _obtain
    if not os.path.exists(self.directory):
      self = <press.press.doctype.tls_certificate.tls_certificate.LetsEncrypt object at 0x7fc285fca170>
  File "/usr/lib/python3.10/genericpath.py", line 19, in exists
    os.stat(path)
      path = None
builtins.TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

Is this supposed to be done outside of the Root Domain/Press Settings configuration? The documentation expects the Root Domain setup to be done first and the TLS certificate issuance is attempted barely minutes after the Root Domain setup is done and it fails. I also noticed that the Documentation says to select Default in the Default Cluster field during the Root Domain setup but there is no Default value and creating default requires additional inputs and the documentation does not have any information on what to provide.

I have also added the Team List as you suggested but the TLS certificate issuance is still returning Index out of range error even though a team list is now created.

Any further tips on resolving these will be appreciated.

Ankush says they are using the GitHub version in frappecloud production now.

Honestly the version is a few years old… I don’t know how to interpret his statement on this. May be I’m wrong. Please see GitHub issue.

Please check if you have any active team and team user is a session user or not.

You might be checking the “release”. We stopped GitHub releases long ago. Checkout the latest commit of master branch.

2 Likes

I don’t think I understand this question but if you’re asking if I created a team and added a user then the answer is yes. the user added is a system user and was given every possible role to ensure nothing was missing. But the errors reported persist.

Did you create a .certbot folder as recommended here, and add it to the press settings ,self.directory returns None ,self.directory refers to the certbot directory in your case it returns None

I suggest you create a user with full admin access(ie Non-Administrator) log in with this user and perform all operations with this user
The get_current_team function which causes this error attempts to get a team using the current session user, if the current session user is Administrator the function will always fail. because the user Administrator cannot be added to a team. and the function doesn’t catch this.

1 Like

if you’re talking about this:


Then yes I did.

I followed your suggestion here and encountered the same outcome.

1 Like

What I meant is the get_current_team function uses the session user to check if the team exists for the user. If you are logged in as Administrator please check if there is a administrator team.

Your webroot folder should be inside the .certbot folder

/home/flexy/.certbot/webroot

so create a webroot folder inside the .certbot folder

Please does anyone here understand how the subscription works for Press

I cant seem to find any documentation on it.

2 Likes

Hello Flexy, did solve issue with TLS?

Yes i did. But i got stuck further down the road and gave up after weeks of trying with no solution.

Where had you stuck?

@HUMENTH Setting up bench in the app server. For some reason the frappe-bench directory is not created after the bench setup process even though that step is marked as completed hence the next step which is the proxy setup process fails as the requisite files and directories are not found.

what’s your servers configuration including bench?