Question
· 19 hr ago

WSGI Flask application in IRIS Container - Where do packages need to be installed?

I'm trying to deploy a python/flask application to an Iris4Health container (2025.1) but running into some issues with packages and where they should be installed. 

First one if the flask packages themselves. I tried to installed the flask packages into the python external language server virtual environment, but even doing this when configuring the WSGI application in the web application section, it would complain about not having a WSGI framework. Once I created a custom container and added the flask package at the OS level, I was able to configure the web application without it complaining.
QUESTION: Is this the preferred method for adding the flask framework? (Creating a custom container with docker build using the iris2025.1 container as the base)

Second, once the flask application is running, what is the preferred method for adding packages. ex: flask-sqlalchamey, flask-session,etc  (that the flask would use)? Again, I tried adding these to the virtual python environment that iris creates (/dev/python/virtual/%Python Server_3252368016$) and then activating the venv and adding package using pip install in the venv.
I did this, but the flask application generates an error that it cannot find the packages... Are you supposed to add these packages the same way, in the base OS images via a docker build command?

Any help with this would be appreciated. i know that the WSGI stuff is listed as "experimental" but seems like this is a better way to host web apps

Product version: IRIS 2025.1
Discussion (1)1
Log in or sign up to continue

After some more debugging here are my findings. It would be beneficial for a Intersystems person to validate these findings.

It appears that in order to use packages in a Flask App deployed to an Iris docker container, you will need to install the packages at the os level of the container. What does this mean? It looks you have to create a custom container using the docker build process and install the needed packages into the new image container, using the base image of the Iris container.

Can someone comment on if this is the suggested way to install packages that a flask would need into a container iris based environment? Kind of defeats the purpose of have a python venv in the container. If you have to create a new base image everytime someone wants to add a package to the flask app, not very dynamic...

Debugging steps:

a. Tried using the base image and deployed a flask app. Getting error message above.
b. Created custom container via docker build with flask packages installed at the OS level. Ex: RUN apt install -y python3-flask
c. Base flask app worked
d. Tried using packages like flask-session, etc application would crash stating it could not find module.
e. Installed packages using the virtual environment in the container (/dev/python/virtual/%Python Server_3252368016$) by first activation the venv, then running pip install. Verified packages were in the correct location
f. Created new container with docker build and adding the packages install into the OS level. Ex: RUN apt install -y python3-flask-session.
g. Started the new container image, Flask app now works as expected.