Runtime Session & Permission Changes for Container deployments #488
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This README explains the recent changes made to
app.py,config.py, and theDockerfileto fix Docker container permission issues and runtime session initialization failures. The goal was to make the application run reliably both with code and container Azure App Service Deployments, without breaking current session functionality.Why The Change Was Needed
When the container was deployed to Azure App Service, it crashed with:
The app ran as a non-root user (
nonroot), and Flask-Session (filesystem backend) tried to create/app/flask_session, which wasn't writable. This required fixing the Docker container's permission structure to properly handle session storage. There were also three duplicated blocks of session initialization logic inapp.pythat caused runtime issues when the container was deployed to App Service.Summary of Changes
config.pySESSION_FILE_DIR(defaults to/app/flask_session).app.pyconfigure_sessions(settings)helper. Removed three duplicated Redis/filesystem setup blocks. Ensured session directory is created early if using filesystem sessions.Dockerfilerootto create venv, install deps, and create/permission/app/flask_session. Final stage copies the pre-permissioned directory.How Session Selection Now Works
redis_urlpresent → Redis backend configured (key or managed identity).SESSION_FILE_DIR(default/app/flask_session).Container Deployment with Azure CLI
To build and deploy the container image to Azure Container Registry:
Navigate to the project directory:
cd simplechat/Set environment variables:
Build and push the image:
Example with actual values:
Environment Overrides (Optional)
You can override the session directory:
(Useful only if persistent storage is enabled and you intentionally want on-disk sessions without Redis.)
Benefits