The contents of this repository should let a user run a dev instance of the Alexandria API through docker.
Currently Alexandria's production environment depends on a few things to be fully functional:
- postgresql
- nginx
- uwsgi
The first is setup by the docker-compose.yml file, but the latter two are currently missing in lieu of Flask's development web server.
-
Run
./build.sh
to clonehermes
locally and build the docker image, which should fail the first time with an error: error: no priv.py file -
Create a local
priv.py
file.- In the
hermes/
directory, copypriv.ex.py
intopriv.py
- Edit
priv.py
so thatskitterClients
is set to an empty list[]
- In the
-
Run
./build.sh
to build the dev container image.
At this point all one-time preparation should be complete.
The main Dockerfile creates a user inside the container matching the host user to match permissions on the mounted source. On docker desktop, mounts are always mounted as root so an alternate desktop.Dockerfile is included which should work better there.
./build.sh
will auto detect whether docker desktop or docker engine is being
used, but can be forced to build one container or the other via the second
argument:
./build.sh engine
or
./build.sh desktop
See also ./build.sh --help
.
-
Start all db and app containers:
docker-compose up -d
which will make Alexandria available onlocalhost:59394
. -
To view logs, use
docker-compose logs app
ordocker-compose logs -f app
to tail the logs. -
The status endpoint can be
curl
ed to check basic sanity:curl http://localhost:59394/v0/status
-
For a more complete check, the lookup endpoint can be used:
curl -s -D/dev/stderr 'http://localhost:59394/v0/lookup?q=FIC_URL_HERE' | jq
The local ./hermes
checkout is mounted into the app container, and the app
container is set to run in dev mode. This means that you can make edits to the
source in ./hermes
and Flask will automatically reload inside the container
to pick up the changes.
If you want to use hermes
directly but don't want to bother configuring an
instance of postgres yourself, you can use the one provided by this
docker-compose file.
By default the db only listens on the docker-compose network. To make it
available to other programs running on your host computer, Uncomment the
ports
definition of the db
container (lines 12-13):
ports:
- "127.0.0.1:15432:5432"
which makes the db accessible on localhost:15432
. If this port is already in
use you will need to change it.
Run docker-compose up -d db
to get docker-compose
to pick up the new ports
assignment.
The hermes
CLI can be pointed to the docker-compose db fairly easily. If you
don't already have a venv for it locally, create it either with the make target:
make venv
or manually via:
cd hermes
python -m venv ./venv
./venv/bin/python -m pip install --upgrade pip
./venv/bin/python -m pip install -r requirements.txt
Then use the OIL_DB_
env variables to point to the docker-compose postgres:
export OIL_DB_HOST=localhost OIL_DB_PORT=15432 OIL_DB_USER=hermes OIL_DB_PASSWORD=pgpass
You can check that hermes
is working by using the info command:
./hermes info FIC_URL_HERE
See its docs/
folder or ./hermes help
for a list of commands and
interactive controls.