1
0
mirror of https://github.com/aziascreations/BakaShrot.git synced 2026-11-23 20:58:46 +01:00

Moved the PureBasic version to OldSource/, Started the Rust rewrite in Source/

The rewrite's plan and decisions are in revamp.md. Steps 0 to 10 are done:
the workspace and checks, bakashrot-proto, bakashrot-pki and
bakashrot-cert, bakashrot-config, bakashrot-storage (schema v9), the
server and the client library (every request but replication's,
attachments and retention included), the C DLL with its C, PureBasic and
Python bindings, and the bakashrot tool. Step 11 (replication) is next.

OldSource/ is the old implementation, kept building and passing as the
reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RwFeVTGs2SsufaH6zquzcb
This commit is contained in:
2026-11-14 12:47:40 +01:00
parent d0048b17c8
commit e044fcf359
225 changed files with 21849 additions and 123 deletions
+81
View File
@@ -0,0 +1,81 @@
# BakaShrot server image.
#
# Built from the repository's root, with the PB-MessagePack submodule checked
# out and a login to the registry holding the PureBasic images (they're
# licensed, so not public):
# git submodule update --init --recursive
# docker login git.nibblepoker.lu
# docker build --provenance=false -t bakashrot-server -f Docker/Server/Dockerfile .
# Another compiler image: --build-arg COMPILER_IMAGE=<image>, any Debian 13
# (trixie) image with PureBasic's compilers on the PATH, gcc and libssl-dev.
#
# Run it with a config and a volume for the database:
# docker run -d --name bakashrot -p 12345:12345 \
# -v ./server.ini:/etc/bakashrot/server.ini:ro \
# -v bakashrot-data:/var/lib/bakashrot \
# bakashrot-server
# In server.ini's [BakaShrot.Server]: Port = 12345, Host empty (every
# interface: 127.0.0.1 can't be reached from outside the container), and
# DatabasePath = /var/lib/bakashrot/server.sqlite (relative paths are from
# that folder too).
#
# Or with docker-compose.yml, next to this file, and its empty server.ini
# to fill in.
#
# `docker stop` stops it cleanly (SIGTERM). Console commands (names, vacuum,
# restart...): start it with -it, then `docker attach bakashrot`, and
# detach with Ctrl+P, Ctrl+Q.
# --- Build ---------------------------------------------------------------------
# PureBasic 6.41 for linux3 (PureBasic's newest Linux build) on
# debian:trixie-slim, the same Debian as the runtime stage below.
ARG COMPILER_IMAGE=git.nibblepoker.lu/packages/purebasic:6.41-linux3-trixie-slim
FROM ${COMPILER_IMAGE} AS build
RUN apt-get update \
&& apt-get install -y --no-install-recommends libsodium-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
# Everything Server/BakaShrot_Server.pb includes, and nothing else.
COPY Client/BakaShrot_ErrorCodes.pbi Client/
COPY Commons Commons
COPY Includes Includes
COPY Server Server
# The release build: C backend, optimized, thread-safe.
RUN mkdir /out && pbcompilerc --thread --optimizer Server/BakaShrot_Server.pb --executable /out/bakashrot-server
# --- Runtime -------------------------------------------------------------------
FROM debian:trixie-slim
# The source label links the package to the repository on ghcr.io. GitHub
# reads it from the image itself, not from an index: build with
# --provenance=false, or the attestation hides it (Docker/README.md).
LABEL org.opencontainers.image.source="https://github.com/aziascreations/BakaShrot" \
org.opencontainers.image.description="BakaShrot server" \
org.opencontainers.image.licenses="CC0-1.0"
# libsodium for the cryptography, SQLite 3.38+ for the storage: the server
# loads libsqlite3.so.0 itself (Server/Storage/Storage.pbi).
RUN apt-get update \
&& apt-get install -y --no-install-recommends libsodium23 libsqlite3-0 \
&& rm -rf /var/lib/apt/lists/*
RUN useradd --system --home-dir /var/lib/bakashrot --shell /usr/sbin/nologin bakashrot \
&& mkdir -p /etc/bakashrot /var/lib/bakashrot \
&& chown bakashrot:bakashrot /var/lib/bakashrot
COPY --from=build /out/bakashrot-server /usr/local/bin/bakashrot-server
USER bakashrot
WORKDIR /var/lib/bakashrot
VOLUME /var/lib/bakashrot
EXPOSE 12345
ENTRYPOINT ["/usr/local/bin/bakashrot-server"]
CMD ["/etc/bakashrot/server.ini"]
@@ -0,0 +1,8 @@
# Only what the server is compiled from: Build/ alone can hold gigabytes of
# test databases, and private keys.
*
!Client/BakaShrot_ErrorCodes.pbi
!Commons
!Includes
!Server
**/.git
@@ -0,0 +1,38 @@
# BakaShrot server, example compose file.
#
# Fill in server.ini next to this file first (a private key, topics, a
# client section: it's empty, the server refuses to start as it is), then,
# from this folder, with a login to the registry holding the PureBasic
# images (see the Dockerfile):
# docker compose up -d --build
# docker compose logs bakashrot # its public key, for client.ini
# docker compose down # stops it cleanly (SIGTERM)
#
# Console commands (names, vacuum, restart...): `docker attach bakashrot`,
# detach with Ctrl+P, Ctrl+Q (not Ctrl+C: that stops it).
#
# The database lives in the bakashrot-data volume, kept by `down`
# (`down -v` deletes it).
services:
bakashrot:
build:
# The repository's root: the build needs Commons/, Includes/, Server/.
context: ../..
dockerfile: Docker/Server/Dockerfile
image: bakashrot-server
container_name: bakashrot
restart: unless-stopped
ports:
# server.ini's [BakaShrot.Server] Port.
- "12345:12345"
volumes:
- ./server.ini:/etc/bakashrot/server.ini:ro
- bakashrot-data:/var/lib/bakashrot
# Only needed to type console commands with `docker attach bakashrot`.
# The server runs fine without these two lines.
stdin_open: true
tty: true
volumes:
bakashrot-data:
+60
View File
@@ -0,0 +1,60 @@
; ============================================================================
; BakaShrot server config, for docker-compose.yml: empty, fill it in.
;
; Every option is documented in Server/Config/schema.ini (config.example.ini
; in a release). Keys: BakaShrotGenerateKeyPairs.exe. Never commit a filled
; in copy, it holds the server's private key.
; ============================================================================
[BakaShrot]
; This server's private key. Its public key, which clients need as
; ServerPublicKey, is in the log when it starts (docker compose logs).
PrivateKey =
; The node this server authenticates as when it links to peers.
Node =
[BakaShrot.Topics]
; One topic name per line.
; logs
[BakaShrot.Retention]
; topic = age (30d, 12h...), or nothing to keep everything forever.
; logs = 30d
[BakaShrot.Server]
; Empty: every interface (127.0.0.1 can't be reached from outside the
; container). The port must match docker-compose.yml's.
Host =
Port = 12345
ReplicatingTopics =
NetThreadPoolSize = 4
; In the bakashrot-data volume.
DatabasePath = /var/lib/bakashrot/server.sqlite
MaxAttachmentSize = 1G
Synchronous = FULL
; One section per peer, see schema.ini.
; [BakaShrot.Peer.other]
; Host =
; Port =
; Node =
; PublicKey =
; One section per client allowed to connect.
[BakaShrot.Client.example]
; The client's public key (client.ini's PublicKey).
PublicKeys =
; The node it writes as (client.ini's Node must say the same).
Node =
; DefaultTopic = logs
; PushTopics = logs
; ReadTopics = *
AllowRead = 1
AllowWrite = 1
AllowQuery = 0