Skip to content

api deploy

Manoel Domingues Junior edited this page Jul 29, 2019 · 2 revisions

Deploy

There are multiple ways to run a Flask application, you can visit the Flask official documentation for deployment.

It was tested with Ngnix + Gunicorn on a Ubuntu (14.04.3) server, and MySQL as database. To initialize the database, run the script "mysqlcreate" inside the script folder. Then install the required python libraries (pip install -r requirements.txt) and the OS packages (requirements.apt).

You should also set some environment variables:

  • MYSQL_DBNAME=gsenha (or whatever if you changed the mysqlcreate script)
  • MYSQL_HOST= your mysql endpoint
  • MYSQL_USERNAME= mysql username
  • MYSQL_PASSWORD= mysql unsername password
  • LDAP_URI= your ldap endpoint, something like ldaps://ldap.example.com. You should (must) use ldapS.
  • LDAP_USER= a ldap user, it can be a read-only user since gsenha will not write in ldap. Something like "cn=ldapuser,ou=User,dc=example,dc=com"
  • LDAP_PASSWORD= ldap user password
  • CERT= complete path to ldap certificate - Not mandatory
  • CLIENT_CERT= complete path to ldap client certificate - Not mandatory
  • CLIENT_KEY= complete path to ldap client key - Not mandatory
  • BASE_GROUP_DN= your base group DN from ldap, something like "ou=Groups,dc=example,dc=com".
  • BASE_USER_DN= your base user DN from ldap, something like "ou=Users,dc=example,dc=com".
  • SECRET_KEY= a complex secret key
  • SMTP_SERVER= your smtp server endpoint
  • EMAIL_SENDER= the email that will be set as the sender, something like "gsenha@example.com"
  • EMAIL_SENDER_NAME= the email sender name, something like "GSenha"

An example of this variables (for docker development environment):

export MYSQL_DBNAME=gsenha
export MYSQL_HOST=mysql.example.org
export MYSQL_USERNAME=gsenha-user
export MYSQL_PASSWORD=gsenha-pass
export LDAP_URI=ldap://ldap.example.org
export LDAP_USER="cn=gsenha,dc=example,dc=org"
export LDAP_PASSWORD=gsenha-pass
export BASE_GROUP_DN="ou=Groups,dc=example,dc=org"
export BASE_USER_DN="ou=Users,dc=example,dc=org"
export SECRET_KEY=04334DA9-440F-4658-9F05-403A39995439
export SMTP_SERVER=smtp.example.org
export EMAIL_SENDER=gsenha@example.org
export EMAIL_SENDER_NAME=Gsenha