Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6e48f0d
Add submodules for OPResource + OPDB
clouths Mar 15, 2026
5af7381
Add container support using linux containers, add migration script fo…
clouths Mar 15, 2026
26512e6
Update mssql-tools to a more recent version (18) to fix migration, up…
clouths Mar 16, 2026
0689ed4
Fix comment in .env.local, remove preparePatch from the migration scr…
clouths Mar 16, 2026
1073ced
Move db persistent storage into a docker volume
clouths Mar 17, 2026
0fa79c6
Most fo the refactor from System.Drawing to SkiaSharp is done.
clouths Mar 21, 2026
decdcfd
Fix migration order of copy to ensure the generated perpetuum.ini is …
clouths Mar 21, 2026
67f8314
Add DefinitionConfig refactor
clouths Mar 21, 2026
b31e821
Update db submodule + migration script to use P34 and P35 full sql files
clouths Mar 21, 2026
1eba63b
Update port mapping to allow more ports for the server to fix black s…
clouths Mar 24, 2026
984ed0a
Fix port mapping, defined extra SERVER_PORTS for port range to forewa…
clouths Mar 24, 2026
0bf693c
Disable EnlistTransactaction
clouths Mar 25, 2026
c19dedf
Add documentation in the readme for how to setup the containers, make…
clouths Mar 28, 2026
17c38fa
Update db image to use mssql-2025
clouths Mar 28, 2026
afe07ea
Fix WithCanvas extension to preserve the Bitmap using SKCanvas instea…
clouths Mar 28, 2026
cba0e76
Fix font.size to use Size property
clouths Mar 28, 2026
8a40610
Fix pixel check to use Alpha instead of the Luminance
clouths Mar 29, 2026
005b8ce
Fix typo, replace usage of manual creation of Area with size.ToArea()…
clouths Mar 29, 2026
14a1e65
Fix PresenceConfiguration to use the Configuration size instead of th…
clouths Mar 29, 2026
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
48 changes: 48 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Environment for local development.
# Compatible with podman/docker with linux containers.

# Database settings
DB_PASSWORD="l3<Nv2-QIat4YK*ydt#u-^+VAAVVdytL"

# Uncomment to force a reset of the DB + run migration
# FORCE_MIGRATION="true"

# Port mapping setting
# Here you can modify the default values
# Only the SERVER and the ASSET ports are required
# The SERVER port is used to allow access to the server when you connect your client
# The SERVER ports is a range that needs to start from the SERVER_PORT + ~300
# Note Without proper SERVER_PORTS, the client will have a black screen when entering a zone
# The ASSET port is used by the client to fetch assets when connecting to the server
# The DB port is optional, used for debugging
SERVER_PORT=17700
SERVER_PORTS=17700-17900
ASSET_PORT=16999
DB_PORT=16998

ASSET_URL="http://localhost:${ASSET_PORT}"

GAME_ROOT="/data"

# Original data directory from Stream: Perpetuum Dedicated Server installer
PERPETUUM_DATA="./perpetuum-data"

# User-provided additional map layers assets
# TODO: Move to a guide/readme
# Required if you want to load the server with Gamma Islands
# Download URL: https://drive.google.com/file/d/1qDjPHbTSdal_aKN6SvYC_EoGW-COkwhJ/view?usp=sharing
# sha256sum:
# f4d42d5dbf6a61d2d7730b2058f5d2bb80a63d0994bbc84b906f19441bb8e425 GAMMA_LAYERS_2021_10_17_P26.rar
CUSTOM_LAYERS="./custom-layers"

# Connection string: Specific changes made to work on linux:
# - Added "sa" user, password to use SQL server authentication;
# - Added TrustServerCertificate=True to trust the self-signed certificate
# - Changed Server to the name of the database container: "db"
# - Removed due to incompatibility on linux: "Connection Reset=True;"
# - Removed Trusted_Connection since we don't want to use Windows Authentication (SPPI)
CONNECTION_STRING="Server=db;Database=perpetuumsa;User Id=sa;Password=${DB_PASSWORD};TrustServerCertificate=True;Pooling=True;Connection Timeout=30;Connection Lifetime=260;Min Pool Size=20;Max Pool Size=60;"


RUNTIME_IDENTIFIER="linux-x64" # TODO env for windows as well (windows-x64)
DISTRIBUTED_TRANSACTIONS=false # .NET on linux does not support Distributed Transactions
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ src/Perpetuum.ServerService2/data/layers/
src/Perpetuum.ServerService2/data/logs/
bin/
Releases/

custom-assets/

# User-provided additional map layers assets
custom-layers/

# Original directory folder from Stream: Perpetuum Dedicated Server installer
perpetuum-data/
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "db"]
path = db
url = https://github.com/OpenPerpetuum/OPDB.git
[submodule "asset"]
path = asset
url = https://github.com/OpenPerpetuum/OPResource.git
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
help:
@echo "Commands to compile, deploy, log services used to run an OpenPerpetuum server (used for local development)"

# Create and start the containers
up:
./script/compose.sh up -d --build --remove-orphans --wait

# Start the containers
start:
./script/compose.sh start

# Stop the containers
stop:
./script/compose.sh stop

# Stop and delete the containers
down:
./script/compose.sh down

# Stop and delete the containers, also delete the volumes (openperpetuum-data, openperpetuum-db)
delete:
./script/compose.sh down -v

# Stop, delete and start the containers
restart: down up

log-asset:
./script/compose.sh logs asset -f

log-db:
./script/compose.sh logs db -f

log-server:
./script/compose.sh logs server -f

phonyx: help up start stop down log-asset log-db log-server
110 changes: 110 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,113 @@

# The Open Perpetuum Server 2

## Setup (container)

This section explains how to setup for local development using docker/podman compose containers where it can be controlled using some make commands.

Here is some context for how this works:

The entry point is `compose.yml` which contains the containers, volumes and network definitions.

There are 2 volumes:
- `openperpetuum-data`: contains the original `PerpetuumServer/Data` + custom layers + generated perpetuum.ini
- `openperpetuum-db`: contains the database files for persistence

There is an environment file to control most of the configuration of this setup:
- `.env.local`

### 0. Requirements
- (optional) make (to help with docker-compose commands)
- docker/podman
- Steam: Perpetuum Dedicated server installed
- Latest gamma islands layers: https://drive.google.com/file/d/1Xp0T1K57Pv-vjgmpXMG8Iea_ec0bWYR4/view?usp=drive_link
- Latest asset resource: https://drive.google.com/file/d/18fh8aRqMP1J7ycGBNGraFyQ31mMXZaq1/view?usp=drive_link

### 1. Clone this repository and update submodules

Start by cloning this repository
```sh
git clone https://github.com/OpenPerpetuum/PerpetuumServer2.git
```
or
```sh
git clone git@github.com:OpenPerpetuum/PerpetuumServer2.git
```

Checkout on the develop branch
```sh
git checkout develop
```

This repository contains 2 submodules.
- db: (OPDB) database migration files for each game update
- asset: (OPResource) game client resources that are fetched once the client connect to the server. Contains definition files for all game entities, translations, gfx, map data (layers), audio files, custom bot models.

You can initialize and update them with this command:
```sh
git submodule init && git submodule update
```

### 2. Update custom resources

This section must be performed if there are updates on the gamma layers or asset resource.

- Uncompress gamma layers into a temporary directory
- Copy gamma layers in `asset/lang0000/layers/GAMMA_LAYERS_NEW` (all .bin files)
- Create `custom-layers` directory
- Copy gamma layers in a new directory `custom-layers` (all .bin files) (the same one as above)
- Unarchive asset resource into a temporary directory
- Copy asset resource into `asset/lang0000` directory (gfx, sfx, textures)
- Create `perpetuum-data` directory
- Copy original PerpetuumServer/data folder into `perpetuum-data` (database, layers)


### 3. Run the server

At this point, you are ready to run the server.

Note: Take a look at the `.env.local` if you need to see what ports are used, what is the database password, or if you want to update various paths.

#### 3.1. Start

```sh
make up
```

This will build and start containers. The migration will run. Once the command exit, you might need to wait for a few minutes since the server is starting up.

You can monitor the server status with this command:
```sh
make log-server
```

If you see logs like `Unit enter to zone` or `Planthandler STOP SIGNAL received`, then the server is ready for a client to connect.

#### 3.2. Setup client with that local server
- Open the client
- Click on `Server list`
- Click on `ADD PRIVATE SERVER`
- Enter Name: `local`, Server address: `127.0.0.1:17700` (update the port to match your `SERVER_PORT` from the `.env.local` file)
- Click `OK`

#### 3.3. Connect client to the local server
- Select `local` in the server list
- Click `Connect` (this might take a few minutes to load, at this point the asset server is transfering files to the client)
- Login with the test account user: `test`, password: `test`

#### 3.4 Stop the server
```sh
make down
```

This will stop and delete the containers but keep the data and db volumes

#### 3,5 Stop and delete server data
```sh
make delete
```

This will stop and delete all data such as containers and volumes (data, db)



1 change: 1 addition & 0 deletions asset
Submodule asset added at 19b6b7
86 changes: 86 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
services:
asset:
build:
context: ./asset
dockerfile: ../docker/Dockerfile.asset.dev
restart: unless-stopped
networks:
- dev_env
volumes:
- .:/asset
ports:
- ${ASSET_PORT}:1337

db:
image: mcr.microsoft.com/mssql/server:2025-latest
ports:
- ${DB_PORT}:1433
environment:
- ACCEPT_EULA=Y
- MSSQL_SA_PASSWORD=${DB_PASSWORD}
networks:
- dev_env
healthcheck:
test: /opt/mssql-tools18/bin/sqlcmd -S localhost -C -U sa -P "${DB_PASSWORD}" -Q "SELECT 1" -b -o /dev/null
interval: 10s
timeout: 3s
retries: 10
hostname: db
volumes:
# Note for linux/WSL2, it can cause permission denied, fix:
# sudo chown -R 10001:10001 openperpetuum-db
- openperpetuum-db:/var/opt/mssql
# Mount perpetuum database path that contains the perpetuumsa.bak
- "${PERPETUUM_DATA}/database:/data"

migration:
build:
context: .
dockerfile: ./docker/Dockerfile.migration.dev
args:
ASSET_URL: ${ASSET_URL}
CONNECTION_STRING: ${CONNECTION_STRING}
SERVER_PORT: ${SERVER_PORT}
depends_on:
db:
condition: service_healthy
environment:
DB_PASSWORD: ${DB_PASSWORD}
FORCE_MIGRATION: ${FORCE_MIGRATION}
networks:
- dev_env
volumes:
- ./db:/migration
- "${PERPETUUM_DATA}:/base-data"
- "${CUSTOM_LAYERS}:/custom-layers"
- "./src/Perpetuum.ServerService2/data:/perpetuum-service-data"
- openperpetuum-data:/data

server:
build:
context: .
dockerfile: ./docker/Dockerfile.server.dev
args:
RUNTIME_IDENTIFIER: ${RUNTIME_IDENTIFIER}
restart: unless-stopped
networks:
- dev_env
ports:
- ${SERVER_PORTS}:17700-17900
environment:
GameRoot: ${GAME_ROOT}
DistributedTransactions: ${DISTRIBUTED_TRANSACTIONS}
depends_on:
migration:
condition: service_completed_successfully
volumes:
- openperpetuum-data:/data


networks:
dev_env:
driver: bridge

volumes:
openperpetuum-data:
openperpetuum-db:
1 change: 1 addition & 0 deletions db
Submodule db added at 049e43
11 changes: 11 additions & 0 deletions docker/Dockerfile.asset.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Development dockerfile for the asset

FROM node:alpine3.23

WORKDIR /var/www/OPResource

COPY . .

RUN npm install .

CMD ["node", "index.js"]
44 changes: 44 additions & 0 deletions docker/Dockerfile.migration.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM ubuntu:22.04

ARG ASSET_URL
ARG CONNECTION_STRING
ARG SERVER_PORT

# Install dependencies for mssql-tools18
RUN apt-get update && apt-get install -y \
curl \
gnupg \
apt-transport-https \
&& rm -rf /var/lib/apt/lists/*

# Add Microsoft repository
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | tee /etc/apt/sources.list.d/msprod.list

# Install mssql-tools18
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y \
mssql-tools18 \
&& rm -rf /var/lib/apt/lists/*

# Add sqlcmd to PATH
ENV PATH="/opt/mssql-tools18/bin:${PATH}"

WORKDIR /work

COPY script/migration.sh .
COPY template/perpetuum.ini.template .
COPY template/restore_DB_to_original_state.sql .

RUN mv perpetuum.ini.template perpetuum.ini

RUN sed -i "s/{SERVER_PORT}/${SERVER_PORT}/" perpetuum.ini
# Update the connection string but hides the command to hide the password
RUN set +x && \
sed -i "s/{CONNECTION_STRING}/${CONNECTION_STRING}/" perpetuum.ini && \
set -x
# Using # delimiter to avoid conflict with / from the url
RUN sed -i "s#{ASSET_URL}#${ASSET_URL}#" perpetuum.ini



ENTRYPOINT ["/work/migration.sh"]
Loading
Loading