researchcloud-items

Installation scripts for SURF ResearchCloud catalog components

View the Project on GitHub UtrechtUniversity/researchcloud-items

Role flask_app

back to index

Summary

Serves an arbitrary Flask app, which runs on localhost using uWSGI, using Nginx as a reverse proxy. The Flask app is installed either from a public git repository, or from PyPi. The role allows easily enabling authentication for your webapp, using SRAM and Single Sign-On.

The role allows installing the app in the different ways:

  1. From a public git repo
  2. From PyPi (specifying package name and version)
  3. From a requirements file on the target machine. The main advantages of this mode is that it allows you to specify specific dependencies, and that by committing a requirements file to your playbook’s repo, you can use something like Dependabot to keep updating to the latest available version of your app.
    • Note: when using this mode, you must still set the flask_app_pip_pkg variable to the name of the package that contains your app, so the role knows which of the dependencies in the requirements file is the app you want to run!

Requires

Description

The user can define:

  1. Which Flask app to install, by either:
    • setting a URL to the appropriate git repo.
    • setting a PyPi package name
  2. Which version of Python to use.
  3. The location of dependency files, such as requirements.txt or pyproject.toml, relative to the root of the git repo. These will automatically be installed
  4. Whether authentication should be enabled for the webapp.
  5. A number of more advanced settings described below.

The role installs uv to ensure the appropriate Python version for the app is present, and to install the dependencies.

app.py vs wsgi.py

Serving Flask apps with uWSGI is usually done in one of two major ways:

  1. Set the uWSGI wsgi-file option to the location of app.py, which contains a callable app.
  2. Set the UWSGI module option to wsgi:app, indicating that the file wsgi.py in the project contains an app callable.

This role will assume the first method is to be used, except when flask_app_module_path is wsgi.py – in that case, it will automatically set the module config option to wsgi:app.

The user can always modify the uWSGI config by setting the flask_app_uwsgi_config option (see below).

Variables

Many of the variables below are to configure the uWSGI settings. While individual settings have their own variable, note that you can always use either flask_app_uwsgi_config (pass in a dict) or flask_app_uwsgi_config_block (pass in a string) to configure arbitrary settings.

See also

History

2024-2025 Written by Dawa Ometto (Utrecht University)

back to index