If you are using Mac for development, use podman instead of docker. Follow the installation guide to set it up, then follow the below set up.
If using Linux or Windows, you need to make sure you have docker and docker-compose
installed on your system.
Secondly, clone the repository:
git clone git@github.com:ukaea/fair-mast.git
cd fair-mast
Run the development container to start the postgres database, fastapi, and minio containers locally. The development environment will watch the source directory and automatically reload changes to the API as you work.
podman compose \
--env-file dev/docker/.env.dev \
-f dev/docker/docker-compose.yml \
up \
--build
Podman does not shutdown containers on its own, unlike Docker. To shutdown Podman completely run:
podman compose -f dev/docker/docker-compose.yml down
podman volume rm --all
docker-compose \
--env-file dev/docker/.env.dev \
-f dev/docker/docker-compose.yml \
up \
--build
The following services will be started:
- FastAPI REST & GraphQL Server - will start running at
http://localhost:8081
.- The REST API documentation is at
http://localhost:8081/redoc
. - The GraphQL API documentation is at
http://localhost:8081/graphql
.
- The REST API documentation is at
- Postgres Database Server - will start running at
http://localhost:5432
- Postgres Admin Server - will start running at
http://localhost:5050
To create the database and populate it with content we need to get the metadata files. These are stored in the repository using Git LFS.
To retrieve these data files, follow the below instructions in your terminal:
git lfs install
git lfs fetch
git lfs pull
Assuming the files have been pulled successfully, the data files should exist within tests/mock_data/mini
in the local directory. We can
create the database and ingest data using the following command:
podman exec -it mast-api python -m src.api.create /code/data/index
docker exec -it mast-api python -m src.api.create /code/data/index
Verify everything is setup correctly by running the unit tests.
Follow the below instructions to set up the environment.
uv run pytest
To run the production container to start the postgres database, fastapi, and minio containers. This will also start an nginx proxy and make sure https is all setup
docker compose --env-file dev/docker/.env.dev -f dev/docker/docker-compose.yml -f dev/docker/docker-compose-prod.yml up --build --force-recreate --remove-orphans -d
To shut down the production deployment, run the following command:
docker compose --env-file dev/docker/.env.dev -f dev/docker/docker-compose.yml -f dev/docker/docker-compose-prod.yml down
To also destory the volumes (including the metadatabase) you may add the volumes parameter:
docker compose --env-file dev/docker/.env.dev -f dev/docker/docker-compose.yml -f dev/docker/docker-compose-prod.yml down --volumes
Note: Every time you destory volumes, the production server will mint a new certificate for HTTPS. Lets Encrypt currently limits this to 5 per week.
You'll need to download and ingest the production data like so:
mkdir -p data/mast/meta
rsync -vaP <CSD3-USERNAME>@login.hpc.cam.ac.uk:/rds/project/rds-sPGbyCAPsJI/archive/metadata data/
docker exec -it mast-api python -m src.api.create /code/data/index
See the guide to building documentation here