How to run the server in Docker?

The agdb_server can be run in Docker using official Docker image. Optionally you can build the image yourself.

Install Docker

Pull or build the agdb_server image

The image is based on Alpine Linux using musl libc. The image is made available on Docker Hub or GitHub packages:

VendorTagCommandDescription
Docker Hublatestdocker pull agnesoft/agdb:latestEquals latest released version
Docker Hub0.x.xdocker pull agnesoft/agdb:0.x.xReleased version, e.g. 0.10.0
Docker Hubdevdocker pull agnesoft/agdb:devEquals latest development version on the main branch, refreshed with every commit to main
GitHublatestdocker pull ghcr.io/agnesoft/agdb:latestEquals latest released version
GitHub0.x.xdocker pull ghcr.io/agnesoft/agdb:0.x.xReleased version, e.g. 0.10.0
GitHubdevdocker pull ghcr.io/agnesoft/agdb:devEquals latest development version on the main branch, refreshed with every commit to main

If you want to build the image yourself run the following in the root of the checked out agdb repository:

docker build --pull -t agnesoft/agdb:dev -f agdb_server/containerfile .

Run the server

docker run -v agdb_data:/agdb/agdb_data --name agdb -p 3000:3000 agnesoft/agdb:dev

This command runs the server using the default configuration (recommended). It assigns a volume to the data directory for data persistence, gives the container a name (agdb) and publishes the container’s exposed port (3000) to the host. You can publish to a different local port (e.g. 5000:3000 (host:container)) where the container’s port 3000 will be locally accessible on the port 5000.

Test that the server is up with curl

curl -v localhost:3000/api/v1/status # should return 200 OK

Shutdown the server

The server can be shutdown either by stopping the container or programmatically posting to the shutdown endpoint as logged in server admin:

# this will produce an admin API token, e.g. "bb2fc207-90d1-45dd-8110-3247c4753cd5"
token=$(curl -X POST -H 'Content-Type: application/json' localhost:3000/api/v1/user/login -d '{"username":"admin","password":"admin"}')
curl -X POST -H "Authorization: Bearer ${token}" localhost:3000/api/v1/admin/shutdown