ed6af00ff8
- packaging/server/install.sh (Linux, macOS) and install.ps1 (Windows) install the latest release (or --version) from GitHub, check the SHA-256 GitHub publishes for it, and keep releases side by side: <dir>/current points at the one in use, so an update or a rollback is one link, and the game files prepared from the owner's Minecraft stay in <dir>/game-files across updates. - packaging/server/Dockerfile builds the server and the engine; the prepared game files are mounted read-only, and the first start writes server.toml from HORIZON_EULA, HORIZON_WORLD, HORIZON_SEED, HORIZON_PORT, HORIZON_WHITELIST, HORIZON_PLAYERS and HORIZON_OP (`init` reads them too). - `horizon-server service install|uninstall|print` writes and loads a systemd unit (user, or --system), a launchd agent, or a Windows task at logon. It runs the installer's launcher, so updates apply on the next restart. - Releases build horizon-server and ship it beside horizon-ctl and horizon-prepare; PLAY.txt says how to run a server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
2.1 KiB
Docker
41 lines
2.1 KiB
Docker
# horizon-server in a container (docs/server.md, section 3). Build context: the repository root:
|
|
# docker build -f packaging/server/Dockerfile -t horizon-server .
|
|
#
|
|
# The image holds none of Minecraft's files. Prepare them on the host from your own Minecraft 26.3
|
|
# (horizon-prepare --prepare, see packaging/PLAY.txt) and mount the folder it writes, read-only:
|
|
# docker run -d --name horizon -p 25565:25565 --stop-timeout 180 \
|
|
# -v horizon-data:/data \
|
|
# -v /path/to/.local/horizon-client/26.3:/opt/horizon/.local/horizon-client/26.3:ro \
|
|
# -e HORIZON_EULA=true -e HORIZON_WHITELIST=true -e HORIZON_PLAYERS=Alex,Steve -e HORIZON_OP=Alex \
|
|
# horizon-server
|
|
#
|
|
# HORIZON_EULA=true accepts the Minecraft EULA (https://aka.ms/MinecraftEULA) for this server. The first
|
|
# start writes /data/server.toml from HORIZON_* (EULA, WORLD, SEED, PORT, WHITELIST, PLAYERS, OP); later
|
|
# starts use the file. Manage it with `docker exec horizon horizon-server status|cmd|backup|logs ...`.
|
|
FROM rust:1-slim-bookworm AS build
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends pkg-config libasound2-dev libudev-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
WORKDIR /src
|
|
COPY . .
|
|
RUN cargo build --release --locked -p horizon-client --bin horizon-client -p horizon-server --bin horizon-server \
|
|
&& mkdir /out && cp target/release/horizon-client target/release/horizon-server /out/
|
|
|
|
FROM debian:bookworm-slim
|
|
# The game links ALSA and udev even when it runs headless with no sound.
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends libasound2 libudev1 \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& useradd --system --home-dir /data --shell /usr/sbin/nologin horizon \
|
|
&& mkdir -p /data /opt/horizon/.local/horizon-client \
|
|
&& chown horizon:horizon /data
|
|
COPY --from=build /out/ /opt/horizon/
|
|
ENV PATH=/opt/horizon:$PATH \
|
|
HORIZON_NO_AUDIO=1
|
|
WORKDIR /data
|
|
VOLUME /data
|
|
EXPOSE 25565
|
|
USER horizon
|
|
# SIGTERM makes horizon-server stop the game cleanly (it saves first): give it --stop-timeout 180.
|
|
CMD ["sh", "-c", "test -f server.toml || horizon-server init --yes || exit 1; exec horizon-server run"]
|