Skip to content

Unreal Engine dedicated Linux server as Docker container with included Django backend and database for admin tools and dynamic REST-API

Notifications You must be signed in to change notification settings

jodermo/UnrealEngineGameServer

Repository files navigation

Unreal Engine Dedicated Server (Dockerized)

Author: Moritz Petzkapetzka.cominfo@petzka.com

Unreal Engine dedicated Linux server as Docker container with included Django backend and database for admin tools and dynamic REST-API

Features

  • Headless Unreal Engine dedicated server
  • Docker and Docker Compose support
  • Persistent volume for saved data/logs
  • Configurable map, port, and logging
  • Minimal base image (Ubuntu 22.04)

Prerequisites

  • Docker and Docker Compose
  • Access to Unreal Engine GitHub repository
  • Linux or WSL with required build tools

.env Example

# Unreal server
PROJECT_NAME=YourProjectName
UE_PORT=7777
UE_MAP=LobbyMap
UE_LOGGING=1

# Database settings
DB_NAME=uegame
DB_USER=admin
DB_PASSWORD=securepassword

# Optional: superuser for Django admin
CREATE_SUPERUSER=1
DJANGO_SUPERUSER_USERNAME=admin
DJANGO_SUPERUSER_EMAIL=admin@example.com
DJANGO_SUPERUSER_PASSWORD=admin123


# UnrealEngine Build
UNREAL_VERSION=5_6
BUILD_CONFIG=Shipping
PROJECT_DIR=UnrealProjects/YourProjectName
ARCHIVE_DIR=Packaged/YourProjectName
UNREAL_ENGINE_PATH=UnrealProjects/UnrealEngine

Getting Started

1. Package the Server

Use Unreal Editor or automation tools to package your project as a Linux dedicated server, then place the output in the GameServer/ folder.

2. Build the Docker Image

docker-compose build

3. Run the Server

docker-compose up -d

This will expose the server on port 7777 (UDP) and 15000 (TCP by default).

Cleanup

docker-compose down

To remove containers, networks, and volumes (careful with Saved/ data):

docker-compose down -v

Guide to Build Your Unreal Engine Project For Linux Server

File structure overview:

~/UnrealEngineGameServer/   # This respoitory
├── Saved/
├── logs/
├── UnrealProjects/         # Contains source code for project build
│   ├── UnrealEngine/                  
│   │   └── ...                      
│   ├── YourProjectName/                
│   │   ├── Binaries/
│   │   ├── Content/
│   │   ├── Config/
│   │   ├── Source/
│   │   └── YourProjectName.uproject

1. Install Prerequisites

In Linux (or use subsystem on windows), run:

sudo apt update
sudo apt install clang lld cmake make git build-essential libncurses5 libssl-dev libx11-dev \
    libxcursor-dev libxinerama-dev libxrandr-dev libxi-dev libglib2.0-dev libpulse-dev \
    libsdl2-dev mono-devel dos2unix unzip

2. Install UnrealEngine*

*(GitHub access to offical UnrealEngine repository needed )

mkdir -p ~/UnrealProjects
cd ~/UnrealProjects
  • Option A: Clone UnrealEngine via SSH

    git clone --depth=1 -b 5.6 git@github.com:EpicGames/UnrealEngine.git
  • Option B: Clone UnrealEngine via HTTP

    git clone --depth=1 -b 5.6 https://github.com/EpicGames/UnrealEngine.git

3. Run Setup & Generate Project Files

cd ~/UnrealProjects/UnrealEngine
./Setup.sh
./GenerateProjectFiles.sh
make

This builds the Unreal Engine Linux version in WSL. It will take a long time.

4. Build Your Game's Linux Server

mkdir -p ~/UnrealProjects/YourProjectName

Copy your Windows project into this directory or clone from a repo

To build the Linux dedicated server:

cd ~/UnrealProjects/UnrealEngine

Build Scripts

First make it Executable:

sudo chmod +x Scripts/build.sh
sudo chmod +x Scripts/clean_build.sh
sudo chmod +x Scripts/gen_server_target.sh
sudo chmod +x Scripts/copy_project_files.sh

Example Usage:

# Rebuild C++ code only (fast)
./Scripts/build.sh code

# Only blueprint changes
./Scripts/build.sh blueprints

# Full cook for content changes (no code changes)
./Scripts/build.sh content

# Build server binaries
./Scripts/build.sh server

# Full package (default)
./Scripts/build.sh full

# Clean build
./Scripts/clean_build.sh
Mode Description Cook Build Pak Archive
code C++ only, no cook/pak/archive
blueprints Blueprint change only
content Content-only changes
server Server binaries only (new mode) ❌ (manual copy)
full Full cook + pak + archive

YourProjectNameServer is auto-generated when you enable Dedicated Server support.

Ensure you have bUsesSteam=false (if you're not configuring Steam) in DefaultEngine.ini under OnlineSubsystem.

5. Enable Server Target (if not done)

./Scripts/gen_server_target.sh

This creates a file like:

// YourProjectNameServer.Target.cs
using UnrealBuildTool;
using System.Collections.Generic;

public class YourProjectNameServerTarget : TargetRules
{
    public YourProjectNameServerTarget(TargetInfo Target) : base(Target)
    {
        Type = TargetType.Server;
        DefaultBuildSettings = BuildSettingsVersion.V2;
        IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_6;
        ExtraModuleNames.Add("YourProjectName");
    }
}

Clean Unreal Build Cache

Run the following in your project folder, e.g.:

cd ~/UnrealProjects/YourProjectName

Then delete the following folders:

rm -rf Binaries/ Intermediate/ DerivedDataCache/ Saved/

Optional: Force Regenerate Project Files (if needed)

~/UnrealProjects/UnrealEngine/Engine/Build/BatchFiles/Linux/GenerateProjectFiles.sh \
  -project="$(pwd)/YourProjectName.uproject" -game

Rebuild the Project

Clean Build Cache (Optional if Build Breaks or Conflicts)

cd ~/UnrealProjects/YourProjectName

# Remove cached build files
rm -rf Binaries/ Intermediate/ DerivedDataCache/ Saved/

# Optional: Clean Unreal's build state
./UnrealProjects/UnrealEngine/Engine/Binaries/DotNET/UnrealBuildTool.exe -Clean

docker-compose down
docker-compose up --build

If you're just rebuilding code and not changing content:

./UnrealProjects/UnrealEngine/Engine/Binaries/DotNET/UnrealBuildTool.exe -Clean
rm -rf Saved Intermediate DerivedDataCache


docker-compose down
docker-compose up --build

Dynamic Backend-API URLs, Views And Database Generation

Ecample entities.json

(DjangoBackend/config/entities.json)

{
  "Player": {
    "fields": {
      "username": "CharField(max_length=50, unique=True)",
      "email": "EmailField()",
      "score": "IntegerField(default=0)",
      "is_active": "BooleanField(default=True)"
    }
  },
  "Match": {
    "fields": {
      "match_id": "CharField(max_length=32, unique=True)",
      "start_time": "DateTimeField()",
      "end_time": "DateTimeField(null=True, blank=True)",
      "winner": "ForeignKey('Player', on_delete=models.DO_NOTHING, null=True)"
    }
  },
  ... add more fields if needed
}

Troubleshooting

  • Build Error

    e.g.

    Compile Module.GeometryCollectionEngine.2.cpp
    In file included from /home/<username>/UnrealEngineGameServer/UnrealProjects/UnrealEngine/Engine/Intermediate/Build/Linux/x64/UnrealEditor/Development/GeometryCollectionEngine/Module.GeometryCollectionEngine.2.cpp:19:
    /home/jodermo/UnrealEngineGameServer/UnrealProjects/UnrealEngine/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionSceneProxy.cpp:43:10: fatal error: 'GeometryCollectionSceneProxy.ispc.generated.h' file not found
      43 | #include "GeometryCollectionSceneProxy.ispc.generated.h"
          |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    
    

    Solution:

    Install ispc

    cd ~/Downloads
    wget https://github.com/ispc/ispc/releases/download/v1.23.0/ispc-v1.23.0-linux.tar.gz
    
    tar -xvzf ispc-v1.23.0-linux.tar.gz
    cd ispc-v1.23.0-linux
    
    sudo cp bin/ispc /usr/local/bin/
    
    ispc --version
    

About

Unreal Engine dedicated Linux server as Docker container with included Django backend and database for admin tools and dynamic REST-API

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published