A server backend for user-contributed annotations, built with Fastify and RethinkDB.
In development mode, you'll run RethinkDB as a Docker image, and the Fastify API via commandline.
$ cd api
$ docker-compose up
This launches RethinkDB. The admin interface will be available at http://localhost:8080. Then in another terminal:
$ npm install
$ npm run dev
This starts the Fastify server at http://localhost:3000.
In normal production deployment, you'll run the whole stack with Docker. The application consists of three containers:
- RethinkDB
- The Fastify API server
- NGINX as a frontend proxy
First, configure the application secret that is used to verify auth tokens. The secret is shared between the Annotorious server and Luna.
- Create a copy of the file
api/.env.prod.example
namedapi/.env.prod
. Change theAUTH_SECRET
variable in the file. - Then, in the root folder, run:
$ docker-compose up --build
The API is available at http://localhost. Note that the RethinkDB admin interface is not exposed in production.
HTTPS Setup
Installation of HTTPS certificates via Certbot and LetsEncrypt is prepared in the Docker setup, but requires manual steps. The process is based on this guide.
In the CLI-commands below, replace annotation-server.rainersimon.io
with the domain name of your server.
docker-compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ --dry-run -d annotation-server.rainersimon.io
With HTTPS still disabled, download certificate from LetsEncrypt:
docker-compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d annotation-server.rainersimon.io
- Edit NGINX config file in
nginx/conf/default.conf
and uncomment the HTTPS config block. - Restart everything with
docker-compose up --build