├── .env.example ├── .gitignore ├── Dockerfile ├── README.md ├── config └── server.conf ├── docker-compose.yml └── run.sh /.env.example: -------------------------------------------------------------------------------- 1 | STEAM_USERNAME=gaben 2 | STEAM_PASSWORD=xxx 3 | ENABLE_BETA=true 4 | BETA_NAME=community-testing -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | .idea 3 | /battlebit -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Use an official Ubuntu as the base image 2 | FROM ubuntu:latest 3 | 4 | # Set environment variables 5 | ENV DEBIAN_FRONTEND=noninteractive 6 | 7 | # Update and install dependencies 8 | RUN apt-get update \ 9 | && apt-get install --no-install-recommends -y \ 10 | wget \ 11 | ca-certificates \ 12 | libstdc++6 \ 13 | lib32stdc++6 \ 14 | libtinfo5 \ 15 | software-properties-common \ 16 | wine winbind xvfb screen \ 17 | && rm -rf /var/lib/apt/lists/* 18 | 19 | # Install wine32 20 | RUN dpkg --add-architecture i386 \ 21 | && apt-get update \ 22 | && apt-get install --no-install-recommends -y wine32 \ 23 | && rm -rf /var/lib/apt/lists/* 24 | 25 | # Create directories for SteamCMD and BattleBit 26 | RUN mkdir -p /home/steam/steamcmd /home/steam/battlebit 27 | 28 | # Download and install SteamCMD 29 | WORKDIR /home/steam/steamcmd 30 | RUN wget -q https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz \ 31 | && tar -xvzf steamcmd_linux.tar.gz \ 32 | && rm steamcmd_linux.tar.gz 33 | 34 | # Set the working directory 35 | WORKDIR /home/steam 36 | 37 | # Copy the run script into the container 38 | COPY run.sh . 39 | 40 | # Give execute permissions to the run script 41 | RUN chmod +x run.sh 42 | 43 | # Command to start the run script 44 | CMD ["./run.sh"] 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BattleBit Docker 2 | 3 | ### ‼️ PLEASE READ ‼️ 4 | 5 | This repos has gained a few stars in the last couple of weeks so I should share some more infos here:
6 | 7 | Running BattleBit Servers on Linux is highly experimental and will cause weird behaviours such as desync, double packets sent or high ping.
8 | The above mentioned issues appear on the current setup using wine.
9 | 10 | Consider checking out [a fork](https://github.com/jackblk/battlebit-server-docker) of this project by @jackblk that has been updated with a few more features. 11 | 12 | :warning: I strongly advice against running any public servers with this for now :warning: 13 | 14 | --- 15 | 16 | ### How to run: 17 | **1.** Copy the `.env.example` to the `config/` folder, rename it to `.env` and set steam username and password (make sure 2FA is off)
18 | 19 | **2.** Change the `port` to your servers port inside the `docker-compose` file and also make sure you add one port above it (`30000` and `30001` in the example file).
20 | 21 | **3.** Start the containers with `docker compose up -d` after configuring the server inside `config/server.conf`
22 | 23 | **4.** Success!
24 | 25 | --- 26 | 27 | ### FAQ 28 | 29 | - [Question: I'm getting the error 'Couldn't read the package, Disconnected from the master server ()'.](#question-im-getting-the-error-couldnt-read-the-package-disconnected-from-master-server) 30 | - [Question: I can't connect to my server, I have 'Error while joining: NoResponse' on the top left of my screen.](#question-i-cant-connect-to-my-server-i-have-error-while-joining-noresponse-on-the-top-left-of-my-screen) 31 | - [Question: I can't connect to my server, I have 'Failed to connect! : CODE [NoResponse : 1]' on the loading screen.](#question-i-cant-connect-to-my-server-i-have-failed-to-connect--code-noresponse--1-on-the-loading-screen) 32 | 33 | ### Question: I'm getting the error `Couldn't read the package, Disconnected from master server`. 34 | Answer ➜ You're not whitelisted or your firewall prevents the GameServer from registering on the Master server. 35 | 36 | ### Question: I can't connect to my server, I have `Error while joining: NoResponse` on the top left of my screen. 37 | Answer ➜ Something prevents you from connecting to the GameServer. It could be your firewall, using the wrong ports, or not forwarding them correctly. 38 | 1. Make sure you are using the correct ports (the ones you provided to Oki, and the same port +1). 39 | 2. The game uses UDP ports, so ensure the ports are open in your firewall (e.g., ufw). 40 | 41 | ### Question: I can't connect to my server, I have `Failed to connect! : CODE [NoResponse : 1]` on the loading screen. 42 | Answer ➜ This Docker uses ApiEndpoint in the launch args: 43 | 1. If you want to use an API, make sure you're using the correct `IP:port`. If you're running your API server on the host, the IP should be `172.17.0.1`. 44 | 2. If you don't want to use an API, delete the line "-ApiEndpoint=$ApiEndpoint" from `run.sh`. 45 | -------------------------------------------------------------------------------- /config/server.conf: -------------------------------------------------------------------------------- 1 | # Server Settings 2 | Name="Test Server" 3 | Password="abc123" 4 | AntiCheat=none 5 | Hz=60 6 | Port=29999 7 | MaxPing=150 8 | LocalIP=0.0.0.0 9 | VoxelMode=false 10 | # Config 11 | ConfigPath="" 12 | ApiEndpoint=30001 13 | # Server Size 14 | FixedSize=none 15 | FirstSize=tiny 16 | MaxSize=medium 17 | # Gameplay 18 | FirstGamemode=CONQ 19 | FirstMap=valley -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | bbd: 4 | container_name: battlebit-docker 5 | build: 6 | context: . 7 | dockerfile: Dockerfile 8 | volumes: 9 | - ./config:/home/steam/config 10 | - ./battlebit:/home/steam/battlebit 11 | env_file: 12 | - config/.env 13 | ports: 14 | - "29999:29999/udp" 15 | - "30000:30000/udp" 16 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Load environment variables from .env file 4 | source /home/steam/config/.env 5 | 6 | # Set the correct Wine prefix to use user's home directory 7 | export WINEPREFIX=/home/steam/.wine 8 | 9 | # Remove X Server lock 10 | rm -rf /tmp/.X1-lock 11 | 12 | # Set up virtual X server using Xvfb 13 | Xvfb :1 -screen 0 1024x768x16 & 14 | 15 | # Set the DISPLAY environment variable 16 | export DISPLAY=:1 17 | 18 | # Check if SteamCMD directory exists 19 | if [ ! -d "/home/steam/steamcmd" ]; then 20 | echo "SteamCMD directory not found. Make sure you have set up the volume correctly." 21 | exit 1 22 | fi 23 | 24 | # Fix windows newline characters for steam credentials 25 | steamusername=$(echo -n "$STEAM_USERNAME" | sed $'s/\r//') 26 | steampassword=$(echo -n "$STEAM_PASSWORD" | sed $'s/\r//') 27 | betaname=$(echo -n "$BETA_NAME" | sed $'s/\r//') 28 | 29 | # Log in to SteamCMD using the provided credentials 30 | if [ "$ENABLE_BETA" = "true" ]; then 31 | /home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType windows +force_install_dir /home/steam/battlebit +login "$steamusername" "$steampassword" +app_update 671860 -beta "$betaname" validate +quit 32 | else 33 | /home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType windows +force_install_dir /home/steam/battlebit +login "$steamusername" "$steampassword" +app_update 671860 validate +quit 34 | fi 35 | 36 | # Check if the game directory exists 37 | if [ ! -d "/home/steam/battlebit" ]; then 38 | echo "Game directory not found. There might be an issue with downloading the game." 39 | exit 1 40 | fi 41 | 42 | # Read server configurations from /config/server.conf 43 | if [ -f "/home/steam/config/server.conf" ]; then 44 | source /home/steam/config/server.conf 45 | else 46 | echo "Server config file not found: /home/steam/config/server.conf" 47 | exit 1 48 | fi 49 | 50 | # Formulate the arguments for BattleBit executable 51 | battlebit_args=( 52 | -batchmode 53 | -nographics 54 | -lowmtumode 55 | "-Name=$Name" 56 | "-Password=$Password" 57 | "-AntiCheat=$AntiCheat" 58 | "-Hz=$Hz" 59 | "-Port=$Port" 60 | "-MaxPing=$MaxPing" 61 | "-LocalIP=$LocalIP" 62 | "-VoxelMode=$VoxelMode" 63 | "-ConfigPath=$ConfigPath" 64 | "-ApiEndpoint=$ApiEndpoint" 65 | "-FixedSize=$FixedSize" 66 | "-FirstSize=$FirstSize" 67 | "-MaxSize=$MaxSize" 68 | "-FirstGamemode=$FirstGamemode" 69 | "-FirstMap=$FirstMap" 70 | ) 71 | 72 | echo "/-----------------------------/" 73 | echo "Server Settings:" 74 | echo "Name: $Name" 75 | echo "Password: $Password" 76 | echo "AntiCheat: $AntiCheat" 77 | echo "Hz: $Hz" 78 | echo "Port: $Port" 79 | echo "MaxPing: $MaxPing" 80 | echo "LocalIP: $LocalIP" 81 | echo "VoxelMode: $VoxelMode" 82 | echo "ConfigPath: $ConfigPath" 83 | echo "ApiEndpoint: $ApiEndpoint" 84 | echo "FixedSize: $FixedSize" 85 | echo "FirstSize: $FirstSize" 86 | echo "MaxSize: $MaxSize" 87 | echo "FirstGamemode: $FirstGamemode" 88 | echo "FirstMap: $FirstMap" 89 | echo "/-----------------------------/" 90 | echo "Launching the BattleBit game server..." 91 | 92 | # Run the BattleBit game server using Wine with the formulated arguments 93 | cd /home/steam/battlebit 94 | 95 | # Redirect stdout to the log file 96 | exec wine ./BattleBit.exe "${battlebit_args[@]}" 97 | --------------------------------------------------------------------------------