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
- Windows: https://www.docker.com/products/docker-desktop/
- Linux: https://docs.docker.com/desktop/setup/install/linux/
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:
Vendor | Tag | Command | Description |
---|---|---|---|
Docker Hub | latest | docker pull agnesoft/agdb:latest | Equals latest released version |
Docker Hub | 0.x.x | docker pull agnesoft/agdb:0.x.x | Released version, e.g. 0.10.0 |
Docker Hub | dev | docker pull agnesoft/agdb:dev | Equals latest development version on the main branch, refreshed with every commit to main |
GitHub | latest | docker pull ghcr.io/agnesoft/agdb:latest | Equals latest released version |
GitHub | 0.x.x | docker pull ghcr.io/agnesoft/agdb:0.x.x | Released version, e.g. 0.10.0 |
GitHub | dev | docker pull ghcr.io/agnesoft/agdb:dev | Equals 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