This repository contains an API and Dockerfile for containerised CTSM applications.
To run the services locally or with docker, first you need to create a .env
file in your project root directory.
You can use env-example
as a template and adjust the variables accordingly. See the Variable
section below for more information.
Cases are supposed to run in docker, though you can also run them locally. To see what dependencies are needed for a local run, check out
docker/Dockerfile
.
We recommend using a virtual environment for your project.
You can either use Conda or Python venv to create a virtual environment, though conda is not tested.
- Make sure Poetry is installed in your environment.
- Install the dependencies:
poetry install
. - Set up the database:
./scripts/migrations_forward.sh
. - Run the dev server:
./scripts/run_dev_server.sh
.
Install docker and docker-compose first.
The current configs and commands are tested with docker 20.10.13 and docker-compose 1.29.2.
- To build the image locally, run
docker-compose -f docker-compose.dev.yaml build
. - To run the docker services in debug mode, run
docker-compose -f docker-compose.dev.yaml up
. - For production, run
docker-compose up
.
In order to avoid permission issues on folders handled by docker,
you can set HOST_USER
and HOST_UID
variables to their respective values for the host user under which you are running the docker commands.
You can do this either in your .env
file or by exporting them in your environment.
THe following command is an example of how to set the variables:
HOST_USER=$(whoami) HOST_UID=$(id -u) docker-compose -f docker-compose.dev.yaml up
See docker/entrypoint.sh
to see how permissions are updated when running the docker services.
Variable | Required | Description | Default | Scope |
---|---|---|---|---|
MODEL_REPO | No | The model repository to use | https://github.com/ESCOMP/CTSM/ | API/Docker |
MODEL_VERSION | Yes | The model repository tag to use | - | API/Docker |
PORT | No | The port to use for API service in docker | 8000 | Docker |
HOST_USER | No | Docker host user. If specified for a docker container, ownership of all folders within resources will be changed to the container host userIt must be used with HOST_UID |
- | Docker |
HOST_UID | No | UID of docker host user. See HOST_ID above and the docker section for more info |
- | Docker |
TODO: describe the resources and how they must be set up.