version 1.5.1
fix restoring endpoints that had been added after
version 1.5.0
Pro Custodibus is a service that makes WireGuard networks easy to deploy and manage. You run the Pro Custodibus agent on each WireGuard host you want to manage, and the agent monitors and synchronizes the hosts' WireGuard settings with the remote Pro Custodibus service.
This repo contains the on-premises API server for the Pro Custodibus service. It is an Elixir Phoenix application. It's meant to be run in conjunction with the app UI and a PostgreSQL database.
The API server can be installed as a Docker container along with the other components of the Pro Custodibus on-premises editions.
Alternatively, the API server can be installed as a native application. However, its binaries must be built on a machine (or in a VM or container) that has the same CPU architecture and core libraries as the machine on which it will be run. Pre-built binaries can be downloaded from the Downloads Page.
To build custom binaries in a container, find the existing Dockerfile in the build/dist
directory that matches the OS of the machine on which the API server will be run (or create a new Dockerfile if you don't find an exact match). Then run the following command, specifying the OS for which to build:
make dist OS=fedora-39
The machine on which you run the API server must have the en_US.UTF-8
locale definition and the following libraries installed:
After installing these libraries, copy over and extract the built API tarball that matches the machine's architecture and OS. Copy the extracted api/example.env
file as /etc/defaults/procustodibus-api
, and move the extracted api/
directory into the /srv/procustodibus/
directory:
scp _build/dist/procustodibus-api-ce-1.2.3-Linux-fedora-39.tar.bz2 api.example.com:.
ssh api.example.com
tar xf procustodibus-api-ce-1.2.3-Linux-fedora-39.tar.bz2
sudo cp api/example.env /etc/default/procustodibus-api
sudo mkdir /srv/procustodibus
sudo mv api /srv/procustodibus/api
Use the /srv/procustodibus/api/ops/db/init.sql
file as a template to initialize the database. Edit the environment variables of the /etc/default/procustodibus-api
file as necessary:
vi /srv/procustodibus/api/ops/db/init.sql
psql --host db.example.com --user postgres --password < /srv/procustodibus/api/ops/db/init.sql
vi /etc/default/procustodibus-api
Then run the API with those environment variables:
(set -a; . /etc/default/procustodibus-api; /srv/procustodibus/api/ops/run/start.sh)
See the Install Guide for full details.
The API server Docker images can be built with the following command:
make docker
Two separate container repositories are maintained for the API:
Run either image after creating a configuration file (eg api.env
) with environment variables based on this example template:
https://git.sr.ht/~arx10/procustodibus-api/tree/main/item/env.example
Then run the following command:
docker run \
--env-file api.env \
--name procustodibus-api \
--publish 4000:4000 \
--rm \
procustodibus/api-ce
However, you usually will want to run it in the same Docker network as the database and app UI. See the Install Guide for full details.
List all Make tasks you can run:
make help
Set up dev database and Docker image (required for all other tasks):
make init
Run linting and tests:
make check
Run unit tests from a file in watch mode:
make watch TEST=test/api_web/controllers/page_controller_test.exs
Run the dev server (with an IEx shell) at http://10.242.4.242:4000/
:
make dev
Run an IEx shell under the test env:
make iex
Start a shell in the dev Docker container from which to run Mix commands:
make shell
jose@e45607da324d:/srv/api$ mix help
Start a shell in the database Docker container from which to run SQL commands:
make shell.db
postgres=# \c custos
Copyright (c) 2019-2024 Arcem Tene, Inc.
See the LICENSE file for license terms.