Add admin port support with other major refactorations
This commit is contained in:
5
docker/.dockerignore
Normal file
5
docker/.dockerignore
Normal file
@@ -0,0 +1,5 @@
|
||||
OpenTTD-patches/.git
|
||||
OpenTTD-patches/build
|
||||
config
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
60
docker/Dockerfile
Normal file
60
docker/Dockerfile
Normal file
@@ -0,0 +1,60 @@
|
||||
# Build stage
|
||||
FROM debian:bookworm AS builder
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
cmake \
|
||||
git \
|
||||
libcurl4-gnutls-dev \
|
||||
liblzma-dev \
|
||||
liblzo2-dev \
|
||||
libpng-dev \
|
||||
libzstd-dev \
|
||||
zlib1g-dev \
|
||||
pkg-config \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /src
|
||||
COPY OpenTTD-patches /src/OpenTTD-patches
|
||||
|
||||
WORKDIR /src/OpenTTD-patches/build
|
||||
RUN cmake .. \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DOPTION_DEDICATED=ON \
|
||||
-DOPTION_INSTALL_HTML_DOCS=OFF \
|
||||
-DOPTION_USE_ASSERTS=OFF \
|
||||
&& make -j$(nproc) install
|
||||
|
||||
# Runtime stage
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libcurl3-gnutls \
|
||||
liblzma5 \
|
||||
liblzo2-2 \
|
||||
libpng16-16 \
|
||||
libzstd1 \
|
||||
zlib1g \
|
||||
ca-certificates \
|
||||
openttd-opengfx \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy binaries from builder
|
||||
COPY --from=builder /usr/local/games/openttd /usr/local/bin/openttd
|
||||
COPY --from=builder /usr/local/share/games/openttd /usr/local/share/games/openttd
|
||||
|
||||
# Ensure base graphics are in a path openttd searches
|
||||
RUN mkdir -p /usr/local/share/games/openttd/baseset && \
|
||||
cp -r /usr/share/games/openttd/baseset/* /usr/local/share/games/openttd/baseset/
|
||||
|
||||
# Create openttd user
|
||||
RUN useradd -m -u 1000 openttd
|
||||
USER openttd
|
||||
WORKDIR /home/openttd
|
||||
|
||||
# Create config directory
|
||||
RUN mkdir -p /home/openttd/.local/share/openttd/save
|
||||
|
||||
EXPOSE 3979/tcp 3979/udp 3977/tcp
|
||||
|
||||
CMD ["openttd", "-D"]
|
||||
37
docker/README.md
Normal file
37
docker/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# OpenTTD JGRPP Docker Server
|
||||
|
||||
This setup builds OpenTTD with the JGR Patch Pack (JGRPP) from source and runs it in a Docker container.
|
||||
|
||||
## Getting Started
|
||||
|
||||
1. **Build and start the server:**
|
||||
```bash
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
2. **Accessing the console:**
|
||||
```bash
|
||||
docker exec -it openttd-jgrpp openttd -D
|
||||
```
|
||||
(Actually, the server runs in dedicated mode. You can view logs with:)
|
||||
```bash
|
||||
docker-compose logs -f
|
||||
```
|
||||
|
||||
3. **Configuration:**
|
||||
The configuration is stored in `config/openttd.cfg`. The default password is set to `asd`.
|
||||
|
||||
4. **Save Games:**
|
||||
Save games are stored in `config/save/`.
|
||||
|
||||
## JGRPP Source
|
||||
The source code is cloned from the `jgrpp` branch of `https://github.com/JGRennison/OpenTTD-patches`.
|
||||
To update the server to a newer JGRPP version:
|
||||
1. Update the `OpenTTD-patches` directory:
|
||||
```bash
|
||||
cd OpenTTD-patches && git pull && cd ..
|
||||
```
|
||||
2. Rebuild the image:
|
||||
```bash
|
||||
docker-compose up -d --build
|
||||
```
|
||||
25
docker/docker-compose.yml
Normal file
25
docker/docker-compose.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
services:
|
||||
openttd:
|
||||
build: .
|
||||
container_name: openttd-jgrpp
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3979:3979/tcp"
|
||||
- "3979:3979/udp"
|
||||
- "3977:3977/tcp"
|
||||
volumes:
|
||||
- ./config:/home/openttd/.local/share/openttd
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
# Use exec to ensure openttd receives SIGTERM directly for autosave_on_exit
|
||||
command: >
|
||||
bash -c "
|
||||
if [ -f /home/openttd/.local/share/openttd/save/autosave/exit.sav ]; then
|
||||
echo 'Found autosave/exit.sav, loading...'
|
||||
exec openttd -D -g save/autosave/exit.sav
|
||||
else
|
||||
exec openttd -D
|
||||
fi"
|
||||
stop_signal: SIGTERM
|
||||
stop_grace_period: 30s
|
||||
Reference in New Issue
Block a user