mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
Run the server headless on Linux, add Docker images for it
The server no longer stops when it has no console input on Linux: it reads its own dup of stdin (taken before OpenConsole(), which closes fd 0; Input() returns "" at EOF there), and SIGTERM/SIGINT stop it like "quit". Windows is unchanged. Docker/Compiler: PureBasic 6.41 on debian:trixie-slim (the archive is copied in by hand and git-ignored). Docker/Server: multi-stage, built with the C backend and the optimizer, run on debian:trixie-slim with libsodium and SQLite only, as user bakashrot; config /etc/bakashrot/server.ini, volume /var/lib/bakashrot, port 12345. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RwFeVQCBfcPDfAPqX8z2TF
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
*
|
||||
!Dockerfile
|
||||
!*.tgz
|
||||
@@ -0,0 +1,2 @@
|
||||
# The PureBasic archive copied here to build the image: licensed, not shared.
|
||||
*.tgz
|
||||
@@ -0,0 +1,22 @@
|
||||
# PureBasic compiler image, console programs only (no GUI libraries).
|
||||
#
|
||||
# PureBasic's Linux build needs glibc 2.38+, hence Debian 13 (glibc 2.41).
|
||||
# The PureBasic archive isn't in git (it's licensed): copy it next to this
|
||||
# file first, then:
|
||||
# docker build -t purebasic:6.41 --build-arg PUREBASIC_ARCHIVE=PureBasic_Linux3_X64_6.41_xxxx.tgz Docker/Compiler
|
||||
# docker run --rm -v "$PWD":/src -w /src purebasic:6.41 pbcompiler -t Server/BakaShrot_Server.pb -e Build/BakaShrot_Server
|
||||
# Both backends are on the PATH: pbcompiler (asm) and pbcompilerc (C).
|
||||
|
||||
FROM debian:trixie-slim
|
||||
|
||||
# gcc links every program (and is the C backend), libssl-dev is for
|
||||
# PureBasic's Network library.
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends gcc libc6-dev libssl-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ARG PUREBASIC_ARCHIVE
|
||||
ADD ${PUREBASIC_ARCHIVE} /opt/
|
||||
|
||||
ENV PUREBASIC_HOME=/opt/purebasic
|
||||
ENV PATH=/opt/purebasic/compilers:$PATH
|
||||
@@ -0,0 +1,65 @@
|
||||
# BakaShrot server image.
|
||||
#
|
||||
# Built from the repository's root, with the compiler image (Docker/Compiler)
|
||||
# already built, and the PB-MessagePack submodule checked out:
|
||||
# git submodule update --init --recursive
|
||||
# docker build -t bakashrot-server -f Docker/Server/Dockerfile .
|
||||
#
|
||||
# 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).
|
||||
#
|
||||
# `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 ---------------------------------------------------------------------
|
||||
|
||||
ARG COMPILER_IMAGE=purebasic:6.41
|
||||
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
|
||||
|
||||
# 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
|
||||
Reference in New Issue
Block a user