Sign inSign up

shonhen/simpleconf

By shonhen

•Updated 16 days ago

Configuration server: one JSON document, read and written by key path over HTTP and TCP.

Image
0

1.0K

shonhen/simpleconf repository overview

⁠simpleconf

A configuration server that holds a single JSON document and lets clients read and write paths inside it, such as app.name, over HTTP or a line-based TCP protocol. Writes go to an append-only file. Several nodes can run as a Raft cluster.

Source, full documentation and benchmarks: https://github.com/shaunlee/simpleconf⁠

⁠Tags

  • latest: the most recent release
  • vX.Y.Z: one tag per release, matching the GitHub releases⁠

Each tag is built for linux/amd64 and linux/arm64. The image is scratch plus one static binary, about 16 MB.

⁠Run

docker run -d --name simpleconf \
  -p 23456:23456 \
  -v simpleconf-data:/data \
  shonhen/simpleconf

Write a value and read it back:

curl -X PUT localhost:23456/db/app.name -d '"demo"'
curl localhost:23456/db/app          # {"name":"demo"}
curl localhost:23456/db              # the whole document

Keep /data on a volume; without one the data is lost with the container. Stop the container with docker stop rather than docker kill: on SIGTERM the server compacts its append-only file and closes it cleanly.

⁠TCP protocol

The TCP protocol is off by default. Turn it on with TCP_LISTEN:

docker run -d --name simpleconf \
  -p 23456:23456 -p 23466:23466 \
  -e TCP_LISTEN=:23466 \
  -v simpleconf-data:/data \
  shonhen/simpleconf
$ printf '=app.name\nPING\n' | nc localhost 23466
$6
"demo"
+PONG

The commands and replies are listed in the README⁠.

⁠Configuration

The image ships /configs/config.yml, which keeps data in /data, serves HTTP on :23456 and leaves Raft off. LISTEN, TCP_LISTEN and DB_DIR override those settings from the environment. For anything else, such as the fsync policy or Raft, mount your own file over it:

# config.yml
db:
  dir: /data
  fsync: always       # always | everysec (default) | no
listen: :23456
tcp:
  listen: :23466
docker run -d --name simpleconf \
  -p 23456:23456 -p 23466:23466 \
  -v "$PWD/config.yml:/configs/config.yml:ro" \
  -v simpleconf-data:/data \
  shonhen/simpleconf

See the README for every setting⁠, what each fsync policy⁠ protects against, and how to set up a Raft cluster⁠.

⁠Docker Compose

services:
  simpleconf:
    image: shonhen/simpleconf:latest    # or pin a release, such as :v0.4.1
    ports:
      - "23456:23456"
    volumes:
      - simpleconf-data:/data
    restart: unless-stopped

volumes:
  simpleconf-data:

⁠Notes

  • There is no authentication and no TLS. Keep the ports on a private network, or put a proxy in front.
  • The image has no shell or curl, so a health check has to run from outside the container: GET / returns the server's role and version.

⁠License

MIT

Tag summary

Content type

Image

Digest

sha256:e127c79ae…

Size

4.8 MB

Last updated

16 days ago

docker pull shonhen/simpleconf