Skip to content

Instantly share code, notes, and snippets.

@OnniSaarni
Last active May 20, 2024 12:23
Show Gist options
  • Save OnniSaarni/a3f840cef63335212ae085a3c6c10d5c to your computer and use it in GitHub Desktop.
Save OnniSaarni/a3f840cef63335212ae085a3c6c10d5c 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 we are going to move on to the next command.

In the next command 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.

@MonstraG
Copy link

MonstraG commented May 11, 2024

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

This sounds like you forgot to add a command here as there is no command after this.

@OnniSaarni
Copy link
Author

OnniSaarni commented May 11, 2024

@MonstraG all the commands were there but it was just worded weirdly from a previous version. Fixed now.

@MonstraG
Copy link

👍

@dotmaxxx
Copy link

Hey im sorry if this is dumb question but I have a problem at the command where you need to replace the path to server its saying "No such image: fika:latest". Im just getting started with docker but am i missing something that i should have downloaded? (an image in this case)

@OnniSaarni
Copy link
Author

@dotmaxxx you ran the docker build command first right?

@dotmaxxx
Copy link

@OnniSaarni yes i did i ran it once more again Im also running this command from Fika folder, i tried server and container folders too. Does it matter where i run it from or i did something wrong while building the image?

@epicylon
Copy link

Easy way to update to latest fika with this?

@MonstraG
Copy link

MonstraG commented May 16, 2024

Did the following to update, played 5-minute raid alone, seems to have worked.

server side

  1. stopped server with docker stop fika
  2. backed up mods and profiles folders in /home/dockercontainers/containers/server/user
  3. deleted old image and container with docker rm and docker rmi
  4. replaced commit and branch versions in Dockerfile:
ARG FIKA=HEAD
ARG FIKA_BRANCH=main
ARG SPT=HEAD
ARG SPT_BRANCH=master

(top commits on stable branches in both repos)

  1. rebuilt:
docker build --no-cache --label FIKA -t fika .
  1. and re-started with very long command that begins with docker run.

client side

  1. found "Upgrading from 3.8.x" in https://dev.sp-tarkov.com/SPT-AKI/Stable-releases/releases and followed those instructions
  2. installed newest fika plugin from https://github.com/project-fika/Fika-Plugin/releases

@hanuriel
Copy link

hanuriel commented May 17, 2024

@MonstraG, You saved my life. Thank you so much.

@OnniSaarni
Copy link
Author

OnniSaarni commented May 18, 2024

Sorry I didn't see the comments. I'll do some updating to this guide this weekend probably. If anyone has any feedback/changes just let me know. Also if you have anything you want to add just comment it here and I'll add it to the guide. A modding guide could be helpful if anyone has any spare time. I'll work on it later though.

@MonstraG
Copy link

I would change docker run to

docker run --pull=never -v /home/dockercontainers/containers/server:/opt/server -p 6969:6969 -p 6970:6970 -p 6971:6971 -p 6972:6972 -it --name fika --log-opt max-size=10m --log-opt max-file=3 fika

The only change is the log opt's: we aren't using Oracle, only have 20gb of storage on our server, and logs ended up growing a bit too big for our taste

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