Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git

8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## local user and group ids
WWWGROUP=1337
WWWUSER=1337

LOCALE=en_US

## cmake build flags
CMAKE_BUILD_TYPE=Release
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 31.0
- Es wurde ein Bug gefixt, der bei Orks das Lernen von
Kampftalenten verlangsamt hat, nicht nur das von allen
anderen.
- Wenn in einem Kampf zwei Heere gleich gute Taktiker haben,
dann ist die Chance, von einem Kämpfer aus dem jeweils
anderen Heer getroffen zu werden nach der neuen Taktikregel
Null. Das hat allerdings nur für Angriffe mit einer Waffe
gegolten, und z.B. nicht für magische Attacken.
- Die Schneekugel macht aus Feuerwänden keine Vulkane mehr.
- Fehler im Gesang der Versklavung, der bei besonders großen
Ziel-Einheiten deren Magieresistenz ausgeschaltet hat.

# 30.4.1
- Verzauberungen, die eigene Daten speichern, müssen Speicher
reservieren, in den sie sie laden (null-pointer crash).
Expand Down
157 changes: 157 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Overview

At this point, the container can mount a game directory from the host, and run the server with a given script like so:
```bash
docker run -v $HOME/eressea/game:/data eressea/server:v1 myscript.lua
```

This mounts the host's `game` directory as a data volume in the container, and the server operated on the files in there, i.e. game data and reports go here.
The script can either be on the data volume, or one of the pre-made scripts in the scripts directory, like newgame.lua, reports.lua, or run-turn.lua. These get copied to /usr/local/share/eressea/scripts during the build process.

## Official Image

If you don't want to build the image yourself, use the latest official image from
the container registry:

```bash
docker pull ghcr.io/eressea/server:latest
```

# Installation (using Docker)

If you want to build the image yourself, because you're planning to make
changes to the source code, follow these steps.

## Install Docker (with compose plugin)

* Debian users, follow https://linuxize.com/post/how-to-install-docker-on-debian-13/
* Ubuntu users, follow https://linuxiac.com/how-to-install-docker-on-ubuntu-24-04-lts/

## Building the image from source

### Clone the Repository

```bash
$ git clone -b develop https://github.com/eressea/server.git ~/eressea/source
$ cd ~/eressea/source
$ git submodule update --init
```

### Configuration

Copy .env.example to .env and modify it. The most importent bit here is using the
same uid and gid as your local user on the host, so files can be shared easily. Use
the id command to find your own values:

```sh
$ id
uid=1000(enno) gid=1000(enno) groups=1000(enno),4(adm),27(sudo),100(users),107(netdev),989(docker)
```

I am enno, my uid is 1000, and my default gid is also 1000. The eressea user in the
container uses 1337 by default, but if I want it to use 1000, that can be achieved
by changing the .env file like this:

```ini
## local user and group ids
WWWGROUP=1000
WWWUSER=1000

LOCALE=en_US

## cmake build flags
CMAKE_BUILD_TYPE=Release
```

You can also change the locale, which will give you system errors in a different language.

### Building the image

Before we can run a container, we need to first build the image. Use
the command `docker compose build` to do that. When you're done,
`docker image ls` should contain the eressea/server:v1 image.


## Create a game directory and a tiny world.

The following steps assume you're using the official image.
If you built your oen image, I recommend that you tag it to
follow along:

```bash
docker image tag eressea/server:v1 eressea/server:latest
```

Create a directory for your first game:

```bash
cd ~/eressea
mkdir game
# for convenience, alias the "docker run" command
alias eressea='docker run -ti -e TERM -v $HOME/eressea/game:/data eressea/server:v1'
eressea newgame.lua
```

After this, your ~/eressea/game directory contains some new files:

`data/0.dat` is a game file that contains a single-hex island with some ocean around it. There are no players in this world (yet).

`eressea.ini` contains a game configuration with sensible defaults for
a game with the E2 ruleset. Modify this with your own email address and
a different ruleset, if you want to. The only built-in rulesets you can choose from are e2 and e3.

## Let's Play
Now let's add a faction to our world and write initial reports.

in the game directory, add a short Lua program named start.lua:
```lua
require 'config'
eressea.read_game('0.dat')
r = get_region(0, 0)
f = faction.create('orc', 'orcs@example.com', 'de')
u = unit.create(f, r)
init_reports()
write_reports()
eressea.write_game(get_turn() .. '.dat')
```

Execute this program:
```
eressea start.lua
```
You should now have reports for your initial faction in the game/reports
directory!

If you would like to use the GM Mapper, you can start that with the built-in map.lua program, just run `eressea map.lua`.

## Custom Rulesets

You can choose to make your own rules, too! Just make the following modifications to your eressea.ini :
```ini
[lua]
;rules = e2
config = rules.json
```
This will instruct the game to not use the e2 ruleset, but a rules.json
file from your game directory. This file could look like this:
```json
{
"settings": {
"game.name": "Discworld",
"game.start": 0
},
"include": [
"config://conf/keywords.json",
"config://conf/calendar.json",
"config://conf/e2/locales.json",
"config://conf/e2/terrains.json",
"config://conf/e2/items.json",
"config://res/eressea/races.xml",
"config://custom/terrains.json",
"config://custom/strings.de.po"
]
}
```
Here, we are instructing the game to borrow some rules from the core game,
like the names of keywords, the calendar, and the races. We also borrow the translations, terrains and items from E2. In addition, we include our own terrains and translations from the game/custom directoory. For their strucuture, refer to the original files and make your own changes!

65 changes: 65 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
FROM ubuntu:24.04 AS build

RUN apt update && \
apt install --no-install-recommends -y \
software-properties-common build-essential gcc cmake \
liblua5.2-dev libtolua-dev libncurses5-dev libsqlite3-dev \
libcjson-dev libiniparser-dev libexpat1-dev libutf8proc-dev

WORKDIR /workspace

COPY CMakeLists.txt eressea/
COPY cmake/ eressea/cmake/
COPY src/ eressea/src/
COPY include/ eressea/include/
COPY storage/ eressea/storage/
COPY clibs/ eressea/clibs/
COPY crpat/ eressea/crpat/
COPY tools/ eressea/tools/
COPY process/CMakeLists.txt eressea/process/

ENV CMAKE_MODULE_PATH=/workspace/eressea/cmake/Modules

RUN cd eressea && ls --recursive /workspace
RUN cd eressea && mkdir -p build
RUN cd eressea/build && cmake ..
RUN cd eressea/build && make

FROM ubuntu:24.04

ARG WWWGROUP
ARG WWWUSER
ARG LOCALE

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install --no-install-recommends -y \
locales libcjson1 \
liblua5.2-0 libsqlite3-0 \
libiniparser1 libexpat1 libutf8proc3
RUN echo "$LOCALE.UTF-8 UTF-8" >> /etc/locale.gen && locale-gen

ENV LC_ALL=$LOCALE.UTF-8
ENV LANG=$LOCALE.UTF-8
ENV LANGUAGE=$LOCALE:en

RUN userdel -r ubuntu
RUN groupadd --force -g $WWWGROUP eressea
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u $WWWUSER eressea

COPY --from=build /workspace/eressea/build/eressea /usr/local/bin/
COPY scripts/ /usr/local/share/eressea/scripts/
COPY conf/ /usr/local/share/eressea/conf/
COPY res/ /usr/local/share/eressea/res/
RUN chmod -R g+rx,o+rx /usr/local/share/eressea

COPY docker/start-container /usr/local/bin/start-container
RUN chmod 755 /usr/local/bin/start-container

USER $WWWUSER:$WWWGROUP

WORKDIR /data

VOLUME ["/data"]

ENTRYPOINT ["/usr/local/bin/start-container"]
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 1998-2022, Enno Rehling <enno@eressea.de>
Copyright (c) 1998-2026, Enno Rehling <enno@eressea.de>

Eressea is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Expand Down
16 changes: 16 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
server:
build:
context: .
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP:-1337}'
WWWUSER: '${WWWUSER:-1337}'
CMAKE_BUILD_TYPE: '${CMAKE_BUILD_TYPE:-Release}'
LOCALE: '${LOCALE:-en_US}'
image: eressea/server:v1
hostname: eressea
environment:
WWWUSER: '${WWWUSER:-1337}'
WWWGROUP: '${WWWGROUP:-1337}'
CMAKE_BUILD_TYPE: '${CMAKE_BUILD_TYPE:-Release}'
25 changes: 13 additions & 12 deletions conf/eressea.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
[game]
email = eressea-server@example.com
sender = Eressea Server
name = Eressea
report = reports
verbose = 0
memcheck = 0
locales = de,en
id = 1
start = 0
email = eressea-server@example.com
sender = Eressea Server
name = Eressea
report = reports
verbose = 0
memcheck = 0
locales = de,en

[lua]
install = .
paths = lunit:scripts
maxnmrs = 20
rules = e2
install = /usr/local/share/eressea
maxnmrs = 5

[editor]
color = 1

color = 1
23 changes: 23 additions & 0 deletions docker/start-container
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

if [ ! -z "$WWWUSER" ]; then
usermod -u $WWWUSER eressea
fi

if [ ! -e eressea.ini ]; then
cp /usr/local/share/eressea/conf/eressea.ini .
fi

export LUA_PATH="/usr/local/share/eressea/scripts/?.lua;/usr/local/share/eressea/scripts/?/init.lua;$LUA_PATH"
SCRIPT="$1"
if [ -e "$SCRIPT" ]; then
shift
elif [ -e "/usr/local/share/eressea/scripts/$SCRIPT" ]; then
SCRIPT="/usr/local/share/eressea/scripts/$SCRIPT"
shift
else
# TODO: debug mode, remove this:
exec "$@"
exit
fi
exec eressea "$@" "$SCRIPT"
2 changes: 1 addition & 1 deletion process/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
install(PROGRAMS create-orders backup-box backup-onedrive
run-turn send-zip-report
run-turn send-zip-report updatelist.sh
send-bz2-report compress.py compress.sh epasswd.py
accept-orders.py getemail.py checkpasswd.py
sendreport.sh sendreports.sh orders-accept DESTINATION bin)
Expand Down
1 change: 1 addition & 0 deletions process/cron/run-eressea.cron
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ backup BACKUP "$GAME" "$TURN"
upload "$BACKUP"
rm -f execute.lock
"$BIN/run-turn" "$GAME" "$TURN"
"$BIN/updatelist.sh" "$TURN"
touch execute.lock

(( NEXTTURN=TURN+1 )) || true
Expand Down
9 changes: 9 additions & 0 deletions process/updatelist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

TURN=$1
LIST=eressea-announce@kn-bremen.de
awk '{ if ($2 =="'$TURN'") print $5 }' deadlog.txt |\
mailman delmembers -f- -l$LIST
tail reports/reports.txt | cut -d: -f2 | sed -e 's/email=//' | \
mailman addmembers - $LIST

6 changes: 1 addition & 5 deletions scripts/config.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
local path = 'scripts'
if config.install then
path = config.install .. '/' .. path
end
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
require 'eressea.path'
require 'eressea'
require 'eressea.xmlconf' -- read xml data

17 changes: 10 additions & 7 deletions scripts/eressea/path.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
local path = '.'
root = os.getenv("ERESSEA_ROOT")
if root then
local path = root .. "/scripts"
package.path = path .. '/?.lua;' .. path .. '/?/init.lua;' .. package.path
end

if config.install then
path = config.install
else
path = os.getenv("ERESSEA_ROOT") or path
config.install = path
local path = config.install .. "/scripts"
package.path = path .. '/?.lua;' .. path .. '/?/init.lua;' .. package.path
eressea.config.add_authority("conf", config.install .. '/conf')
eressea.config.add_authority("res", config.install .. '/res')
end
path = path .. "/scripts"
package.path = path .. '/?.lua;' .. path .. '/?/init.lua;' .. package.path
2 changes: 1 addition & 1 deletion scripts/eressea/xmasitems.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ end

function use_snowglobe(u, amount, token, ord)
local transform = {
-- firewall = "volcano",
ocean = "glacier",
firewall = "volcano",
activevolcano = "volcano",
volcano = "mountain",
desert = "plain"
Expand Down
Loading
Loading