From c5adfe80bc69467a16a80e78ec2e68f33cb4775e Mon Sep 17 00:00:00 2001 From: Tarod BOFH Date: Sat, 27 Apr 2024 14:39:08 +0200 Subject: [PATCH] Forking from https://github.com/TarodBOFH/single-player-tarkov --- .dockerignore | 3 ++ Dockerfile | 34 +++++++++++++++++++++ README.md | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++ entrypoint.sh | 28 +++++++++++++++++ 4 files changed, 148 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..591082f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +/user* +/config* +*.syno.tar diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e9e0faf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +FROM alpine as git +RUN apk add git git-lfs + +FROM git as fetch +ARG SPT_VERSION=3.8.0 +WORKDIR /repo +RUN git clone https://dev.sp-tarkov.com/SPT-AKI/Server.git . && \ + git checkout tags/$SPT_VERSION && \ + git lfs fetch && \ + git lfs pull + +FROM node:20.11.1-alpine AS builder +WORKDIR /app +RUN apk add git git-lfs +COPY --from=fetch /repo . +WORKDIR /app/project +RUN npm install -g npm@10.5.1 +RUN npm run build:release + +FROM alpine as base +RUN apk update && \ + apk --no-cache --update add libgcc libstdc++ libc6-compat && \ + rm -rf /var/cache/apk/* + +From base +WORKDIR /app +COPY --from=builder /app/project/build /app +RUN cp -R /app/Aki_Data/Server /app/Aki_Data/Server.backup +RUN mkdir -p /app/BepInEx/plugins +COPY entrypoint.sh . +RUN chmod +x entrypoint.sh +VOLUME /app/user +VOLUME /app/Aki_Data/Server +ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..d41b306 --- /dev/null +++ b/README.md @@ -0,0 +1,83 @@ +# single-player-tarkov-docker +Private Dockerfile to build a docker container for Single-Player-Tarkov + +# Dependencies + +None + +Note: SPT-AKI does not work as a subtree (can be used as a .gitmodule) because of lfs. I've decided to pull in the image (with a builder) instead of forking / adding the submodule to this repo, as it is standarized in Dockerfiles as per 2024-04 + +# Docker Support + +## Volumes +Two volumes are added: +- `/app/Aki_Data/Server` contains standard `SPT-Aki.Server` database and configuration files. For example, `http.json` or `profiles.json` + The container will copy standard Aki Server files to this volume if emty (i.e. mounted by the very first time) +- `/app/user` with the standard server configuration (will be created on first login) + - `./profiles` contains the player profiles created + - `./mods` installed server mods go here + - `./logs` server logs will appear here + +## Enviroment Variables +- `SPT_LOG_REQUESTS` when false, disables SPT-AKI Request Logging +- `SPT_BACKEND_IP` when present, used in `http.conf` as `backendIp` property + +Feel free to play yourself with the different setups and configs. + +# How to build + +Update `SPT_VERSION` Dockerfile ARG with the desired tag +You can look for the most recent tag with `git describe --tags --abbrev=0` +The way SPT is organizing their release is by tags on release branches. 3.8.0 was not released as a tag on `master` as it was done before. +Note: It can be a good idea to evolve the Dockerfile to include SPT_VERSION for the branch and always use latest tag) + +```bash +docker build -t cbr/spt:latest -t cbr/spt:your-tag-version-here +``` + +--- + + +# Old Documentation + +Some old documentation if moving to local submodule is desired +## Add a submodule for SPT-Aki +```bash +git submodule add https://dev.sp-tarkov.com/SPT-AKI/Server.git SPT-Server +``` + +## Retrieve after adding +```bash +git submodule update --init --recursive +``` +Note: Needs LFS! + +## Stay in Tarkov Submodules +### Add the remotes + +```bash +git remote add -f sit-client git@github.com:stayintarkov/StayInTarkov.Client.git +git remote add -f sit-server git@github.com:stayintarkov/SIT.Aki-Server-Mod.git +git remote add -f sit-manager git@github.com:stayintarkov/SIT.Manager.git +git remote add -f sit-mods git@github.com:stayintarkov/SIT-Mod-Ports.git +``` +### Add the subtrees +```bash +git subtree add --prefix sit-client sit-client master --squash +git fetch sit-client +git subtree pull --prefix sit-client sit-client master --squash + +git subtree add --prefix sit-server sit-server master --squash +git fetch sit-server +git subtree pull --prefix sit-server sit-server master --squash + +git subtree add --prefix sit-manager sit-manager master --squash +git fetch sit-manager +git subtree pull --prefix sit-manager sit-manager master --squash + +git subtree add --prefix sit-mods sit-mods master --squash +git fetch sit-mods +git subtree pull --prefix sit-mods sit-mods master --squash + +``` +Repeat for all the repos in https://github.com/stayintarkov \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..a0cb0d0 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,28 @@ +#!/bin/ash +HOST_CONTAINER_IP=`awk 'END{print $1}' /etc/hosts` +CONTAINER_IP=${HOST_CONTAINER_IP:-127.0.0.1} +BACKEND_IP=${SPT_BACKEND_IP:-127.0.0.1} + +echo "Replacing configuration with container ip_addr $CONTAINER_IP" + +# If configs have been deleted / reset, restore them from our backup when +# building the container +CONFIGS=Aki_Data/Server/configs +if [ ! -d "$CONFIGS" ]; then + cp -R /app/Aki_Data/Server.backup/* /app/Aki_Data/Server +fi + +# Update server ips for listening / accepting connections +HTTP_CONFIG=$CONFIGS/http.json +sed -ir 's/"ip": .*,/"ip": "'$CONTAINER_IP'",/' $HTTP_CONFIG +sed -ir 's/"backendIp": .*,/"backendIp": "'$BACKEND_IP'",/' $HTTP_CONFIG + +# Update Log Requests +if [ $SPT_LOG_REQUESTS = false ]; then + sed -ir 's/"logRequests": true,/"logRequests": false,/g' $HTTP_CONFIG +fi + +APP_DIR=`pwd` + +echo "Running Aki Server" +exec "$APP_DIR/Aki.Server.exe"