Use the flask-framework extension

Note

The Flask extension is compatible with the bare and ubuntu@22.04 bases.

To employ it, include extensions: [ flask-framework ] in your rockcraft.yaml file.

Example:

name: example-flask
summary: A Flask application
description: A rock packing a Flask application via the flask extension
version: "0.1"
base: bare
build-base: [email protected]
license: Apache-2.0

extensions:
  - flask-framework

platforms:
  amd64:

Managing project files with the flask extension

By default the flask extension only includes app.py, static/, app/, and templates/ in the flask project, but you can overwrite this behaviour with a prime declaration in the specially-named flask-framework/install-app part to instruct the flask extension on which files to include or exclude from the project directory in the rock image.

The extension places the files from the project folder in the /flask/app directory in the final image - therefore, all inclusions and exclusions must be prefixed with flask/app.

For example, to include only select files:

parts:
  flask-framework/install-app:
    prime:
      - flask/app/static
      - flask/app/.env.production
      - flask/app/app.py
      - flask/app/templates

To exclude certain files from the project directory in the rock image, add the following part to rockcraft.yaml:

parts:
  flask-framework/install-app:
    prime:
      - -flask/app/.git
      - -flask/app/.venv
      - -flask/app/.yarn
      - -flask/app/node_modules