From 25277530b394cff8456e6baa032f15c871e2ac35 Mon Sep 17 00:00:00 2001 From: wizzdom Date: Sun, 31 Mar 2024 18:48:31 +0100 Subject: [PATCH] api: refactor, add nomad docs (#34) --- docs/services/api.md | 80 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/docs/services/api.md b/docs/services/api.md index 8772af2d..fb01da0f 100644 --- a/docs/services/api.md +++ b/docs/services/api.md @@ -3,33 +3,81 @@ title: API tags: - services - api + - ldap --- -# API - -## Redbrick Administrator Web API +# Redbrick Administrative Web API The source code for the API can be found [here](https://github.com/redbrick/api/). -The Redbrick web API serves as an easy interface to carry out administrator tasks (mainly LDAP related), and for use in automation. This saves time instead of accessing machines, and formulating and executing manual LDAP queries or scripts. +The Redbrick web API serves as an easy interface to carry out administrator tasks *(mainly LDAP related)*, and for use in automation. This saves time instead of accessing machines, and formulating and executing manual LDAP queries or scripts. + +The server code for the API is hosted on [`aperture`](../hardware/aperture/index.md) in a docker container deployed with [`nomad`](nomad.md), the job file for which is [here](https://github.com/redbrick/nomad/blob/master/jobs/services/api.hcl). It is written in Python with [FastAPI](https://fastapi.tiangolo.com/). This container is then served to the public using [`traefik`](traefik.md). + +## Nomad Job File + +The [nomad job for Redbrick's API](https://github.com/redbrick/nomad/blob/master/jobs/services/api.hcl) is similar to most other web servers for the most part. As always, all secrets are stored in [`consul`](consul.md). Some things to watch out for are: + +- The docker image on ghcr.io is private and therefore requires credentials to access. + +```hcl title="Nomad" +auth { + username = "${DOCKER_USER}" + password = "${DOCKER_PASS}" +} +``` + +```hcl title="Nomad" +template { + data = < Note that `USERNAME` can be used to refer to the user's web directory here since it is the name of the directory and doesn't refer to the user object.