Skip to content

alan-turing-institute/misinformation-annotator

Repository files navigation

Misinformation annotator tool

Using the F# SAFE stack - work in progress

See main project for project board and issues.

Requirements

Development mode

The SAFE development stack is designed to be used with minimal tooling. An instance of Visual Studio Code together with the Ionide plugin should be enough.

Start the development mode with:

> build.cmd run // on windows
$ ./build.sh run // on unix

This command will call the target "Run" in build.fsx. This will start in parallel:

  • dotnet fable webpack-dev-server in src/Client (note: the Webpack development server will serve files on http://localhost:8080)
  • dotnet watch msbuild /t:TestAndRun in test/serverTests to run unit tests and then server (note: Giraffe is launched on port 8085)

You can now edit files in src/Server or src/Client and recompile + browser refresh will be triggered automatically. For the case of the client "Hot Module Replacement" is supported, which means your app state is kept over recompile.

Usually you can just keep this mode running and running. Just edit files, see the browser refreshing and commit + push with git.

In development mode, the app runs locally using files from local file system. You can change that by providing it with the Azure connection strings in environment variables for blob storage CUSTOMCONNSTR_BLOBSTORAGE and SQL database SQLAZURECONNSTR_SQLDATABASE. When the environment variables are set, the app runs locally while using data from Azure storage.

Deployment

The deployment for this repo works via docker with Linux containers and therefore you need docker installed on your machine. The deployment is automatic to Azure from Docker Hub.

Docker Hub

The DockerHub repository for the project is turinginst/misinformation.

Release script

To deploy the app, copy the following content to a release.sh script and fill in your DockerHub credentials:

#!/usr/bin/env bash
set -eu
cd "$(dirname "$0")"

PAKET_EXE=.paket/paket.exe
FAKE_EXE=packages/build/FAKE/tools/FAKE.exe

FSIARGS=""
FSIARGS2=""
OS=${OS:-"unknown"}
if [ "$OS" != "Windows_NT" ]
then
  FSIARGS="--fsiargs"
  FSIARGS2="-d:MONO"
fi

run() {
  if [ "$OS" != "Windows_NT" ]
  then
    mono "$@"
  else
    "$@"
  fi
}

DOCKERARGS="Deploy DockerLoginServer=docker.io DockerImageName=misinformation DockerOrg=turinginst DockerUser=CHANGE_ME  DockerPassword=CHANGE_ME"
run $PAKET_EXE restore
run $FAKE_EXE $DOCKERARGS $FSIARGS $FSIARGS2 build.fsx

Don't worry the file is already in .gitignore so your password will not be commited.

Docker push

In order to release a container you need to create a new entry in RELEASE_NOTES.md and run release.sh. This will build the server and client, run all test, put the app into a docker container and push it to your docker hub repo. This triggers a webhook for Azure, which deploys the app.

You should be able to reach the website on misinformation.azurewebsites.net.

Notes

  • The app is deployed using the Azure Web app for containers resource
  • The webhook URL in Azure container settings is used in the Docker hub repo
  • For additional information see SAFE BookStore app

Using the website

For testing purposes, you can log into the website using test/test credentials.