Skip to content

Instantly share code, notes, and snippets.

@SirJson
Forked from OnniSaarni/fikaserver.md
Created May 9, 2024 16:05
Show Gist options
  • Save SirJson/00865cb85b59df54162a4e0eb3b008f9 to your computer and use it in GitHub Desktop.
Save SirJson/00865cb85b59df54162a4e0eb3b008f9 to your computer and use it in GitHub Desktop.
SPT AKI Fika Server With Docker Ubuntu/Debian

Setting up Fika SPT AKI server with docker for Ubuntu/Debian

Last updated: 09/05/24

For support you should join the Fika Discord server

Free VPS

A good free VPS from Oracle. It offers 24gb ram, 4 cores and 200gb of storage. It's ARM but works with this setup.

Installing Docker

First of all you need Docker. You can download it by following this guide here. This guide is for ubuntu but you can find guides for other operating systems/distributions on their website.

You can verify your Docker installation by running docker --version

Creating a user for docker (Recommended)

For better security, it's recommended to set up a separate user for Docker containers.

sudo adduser dockercontainers

To be able to use docker with this user add them to the docker group

sudo groupadd docker
sudo usermod -aG docker dockercontainers

You can log into the new account by entering this command:

su - dockercontainers

Setting up the directories

After you've got docker installed you can start by creating a new directory for your project and navigate to it in your terminal.

I'm going to go ahead and create a new directory called "containers" and navigate to it. You can do this with:

mkdir containers
cd containers

Now we're going to create a new directories for our Fika Dockerfile and Fika SPT AKI server and navigate to the Dockerfile directory. You can do this with:

mkdir fika
mkdir server
cd fika

The file structure looks like this:

folder structure

Creating the files

Now we're going to create a new file called "Dockerfile" in the fika directory. THIS NAME IS CASE SENSITIVE

You can do this with:

nano Dockerfile

Inside this file we're going to write the following: (These are from the Fika Discord)

##
## Dockerfile
## FIKA LINUX Container
##

FROM ubuntu:latest AS builder
ARG FIKA=HEAD^
ARG FIKA_BRANCH=v2.0
ARG SPT=HEAD^
ARG SPT_BRANCH=3.8.1
ARG NODE=20.11.1

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
WORKDIR /opt

# Install git git-lfs curl
RUN apt update && apt install -yq git git-lfs curl
# Install Node Version Manager and NodeJS
RUN git clone https://github.com/nvm-sh/nvm.git $HOME/.nvm || true
RUN \. $HOME/.nvm/nvm.sh && nvm install $NODE
## Clone the SPT AKI repo or continue if it exist
RUN git clone --branch $SPT_BRANCH https://dev.sp-tarkov.com/SPT-AKI/Server.git srv || true

## Check out and git-lfs (specific commit --build-arg SPT=xxxx)
WORKDIR /opt/srv/project
RUN git checkout $SPT
RUN git-lfs pull

## remove the encoding from aki - todo: find a better workaround
RUN sed -i '/setEncoding/d' /opt/srv/project/src/Program.ts || true

## Install npm dependencies and run build
RUN \. $HOME/.nvm/nvm.sh && npm install && npm run build:release -- --arch=$([ "$(uname -m)" = "aarch64" ] && echo arm64 || echo x64) --platform=linux
## Move the built server and clean up the source
RUN mv build/ /opt/server/
WORKDIR /opt
RUN rm -rf srv/
## Grab FIKA Server Mod or continue if it exist
RUN git clone --branch $FIKA_BRANCH https://github.com/project-fika/Fika-Server.git ./server/user/mods/fika-server
RUN \. $HOME/.nvm/nvm.sh && cd ./server/user/mods/fika-server && git checkout $FIKA && npm install
RUN rm -rf ./server/user/mods/FIKA/.git

FROM ubuntu:latest
WORKDIR /opt/
RUN apt update && apt upgrade -yq && apt install -yq dos2unix
COPY --from=builder /opt/server /opt/srv
COPY fcpy.sh /opt/fcpy.sh
# Fix for Windows
RUN dos2unix /opt/fcpy.sh

# Set permissions
RUN chmod o+rwx /opt -R

# Exposing ports
EXPOSE 6969
EXPOSE 6970
EXPOSE 6971

# Specify the default command to run when the container starts
CMD bash ./fcpy.sh

Press Ctrl + S to save and after that press Ctrl + X to exit.

And then we will create a new file called "fcpy.sh" in the fika directory. THIS NAME IS CASE SENSITIVE

You can do this with:

nano fcpy.sh

Inside this file we're going to write the following: (These are from the Fika Discord)

# fcpy.sh

#!/bin/bash
echo "FIKA Docker"

if [ -d "/opt/srv" ]; then
    start=$(date +%s)
    echo "Started copying files to your volume/directory.. Please wait."
    cp -r /opt/srv/* /opt/server/
    rm -r /opt/srv
    end=$(date +%s)
    
    echo "Files copied to your machine in $(($end-$start)) seconds."
    echo "Starting the server to generate all the required files"
    cd /opt/server
    chown $(id -u):$(id -g) ./* -Rf
    sed -i 's/127.0.0.1/0.0.0.0/g' /opt/server/Aki_Data/Server/configs/http.json
    NODE_CHANNEL_FD= timeout --preserve-status 40s ./Aki.Server.exe </dev/null >/dev/null 2>&1 
    echo "Follow the instructions to proceed!"
    exit 0
fi

if [ -e "/opt/server/delete_me" ]; then
    echo "Error: Safety file found. Exiting."
    echo "Please follow the instructions."
     sleep 30
    exit 1
fi

cd /opt/server && ./Aki.Server.exe

echo "Exiting."
exit 0

Setting up the Docker container

After the files have been created we can start the setup.

First off we're going to run this in the "fika" directory:

docker build --no-cache --label FIKA -t fika .

It will take a while but once it is finished run this command in the same directory:

You need to change your "PATHTOYOURSERVERFILE" to your server directory path. To do this you can navigate to the server directory we created earlier. If you are still in the "fika" directory (you can confirm this by running pwd in your current directory), you can navigate to the "server" directory by running:

cd ..
cd server

Then by running pwd you can get the path to your server file. Copy this value and replace it with "PATHTOYOURSERVERFILE".

docker run --pull=never -v PATHTOYOURSERVERFILE:/opt/server -p 6969:6969 -p 6970:6970 -p 6971:6971 -p 6972:6972 -it --name fika fika

Starting the container

docker start fika
docker update --restart unless-stopped fika

After starting the container you can see the logs of it with docker logs fika -f

Helpful Docker commands

To see the logs of the container:

docker logs fika -f

You can use Ctrl + C to exit the logs.

To stop the container:

docker stop fika

To restart the container:

docker restart fika

Modding and other possibly helpful info

To play with your friends you first have to port forward or disable the firewall for port 6969 on the server.

To host Co-Op raids with your friends you either have to have UPnP enabled or have port 25565 forwarded to your PC. You should also disable the firewall for the EscapeFromTarkov.exe and allow ports in the firewall. More info over here

To add more mods to the game you have to add them to the "users" directory in the server directory.

http.json should be pre configured in this docker setup.

Errors

If you're having this error and you have installed the realism mod, you have to do this fix:

[2024-05-03T03:21:21.203Z] error:     TypeError: Cannot read properties of undefined (reading 'replaceAll')
[2024-05-03T03:21:21.204Z] error:     TypeError: Cannot read properties of undefined (reading 'replaceAll')
[2024-05-03T03:21:21.204Z] error:     TypeError: Cannot read properties of undefined (reading 'replaceAll')
    at HttpRouter.getResponse (/opt/server/user/mods/mpt-server/src/overrides/routers/HttpRouter.ts:29:41)
    at AkiHttpListener.getResponse (/snapshot/src/servers/http/AkiHttpListener.ts:150:38)
    at AkiHttpListener.handle (/snapshot/src/servers/http/AkiHttpListener.ts:39:39)
    at HttpServer.handleRequest (/snapshot/src/servers/HttpServer.ts:103:26)
    at Server.<anonymous> (/snapshot/src/servers/HttpServer.ts:45:18)
    at Server.emit (node:events:518:28)
    at parserOnIncoming (node:_http_server:1151:12)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
[2024-05-03T03:21:21.203Z] error:     TypeError: Cannot read properties of undefined (reading 'replaceAll')
    at HttpRouter.getResponse (/opt/server/user/mods/mpt-server/src/overrides/routers/HttpRouter.ts:29:41)
    at AkiHttpListener.getResponse (/snapshot/src/servers/http/AkiHttpListener.ts:150:38)
    at AkiHttpListener.handle (/snapshot/src/servers/http/AkiHttpListener.ts:39:39)
    at HttpServer.handleRequest (/snapshot/src/servers/HttpServer.ts:103:26)
    at Server.<anonymous> (/snapshot/src/servers/HttpServer.ts:45:18)
    at Server.emit (node:events:518:28)
    at parserOnIncoming (node:_http_server:1151:12)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)

I was also having an error which was fixed by deleting all the files in the "cache" directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment