Service Environment

When running mvi init a folder .s2i is created containing the file environment. By default, it only contains a single row:

APP_FILE = service.py

This tells Source-To-Image, which is used internally to convert code into a deployable container image, that service.py is the main file of the service. It just defines an environment variable called APP_FILE, like you would do in linux with:

>>> export APP_FILE=service.py  

By setting environment variables this way you can add configuration for your services without having to make changes in the code. To read environment variables in the service code you can use the os module available in standard python:

import os

envvar = os.environ.get("ENV_VAR")

MVI Service Configuration

There are some special environment variables that are used for MVI service configuration.

Environment Variable

Explanation

Example

MVI_SERVICE_DB_TABLE_LIMIT

Format <number><limiter>. Limiter options: "rows", "days", "hours", "minutes" or "seconds".

MVI_SERVICE_DB_TABLE_LIMIT=30days