Skip to content

Commit b1502fb

Browse files
author
Laura Demkowicz-Duffy
committed
feat: first working version
1 parent 6463b5a commit b1502fb

File tree

6 files changed

+64
-39
lines changed

6 files changed

+64
-39
lines changed

.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Containerfile
2+
Makefile
3+
LICENSE
4+
README.md

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
game_files*

Dockerfile

+23-39
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,43 @@
1-
FROM steamcmd/steamcmd AS steambuild
2-
# REPO_SETUP: Add maintainers
1+
FROM fragsoc/steamcmd-wine-xvfb
2+
# Maintainer: Laura Demkowicz-Duffy <[email protected]>
33

44
ARG UID=999
55
ARG GID=999
66

77
ENV CONFIG_LOC="/config"
8-
ENV INSTALL_LOC="/GAME_NAME"
8+
ENV LOG_LOC="/logs"
9+
ENV INSTALL_LOC="/carriercommand"
910
ENV HOME=${INSTALL_LOC}
1011
ENV DEBIAN_FRONTEND="noninteractive"
1112

1213
USER root
1314

14-
# REPO_SETUP: Append any packages that your server needs to the
15-
# REPO_SETUP: `apt install` line.
1615
RUN apt update && \
1716
# Install libsdl, used by steamcmd
18-
apt install -y --no-install-recommends libsdl2-2.0-0
17+
apt install -y --no-install-recommends libsdl2-2.0-0 winbind
1918

2019
# Setup directory structure and user permissions
2120
RUN mkdir -p $INSTALL_LOC && \
22-
groupadd -g $GID GAME_NAME && \
23-
useradd -m -s /bin/false -u $UID -g $GID GAME_NAME && \
24-
mkdir -p $CONFIG_LOC $INSTALL_LOC && \
25-
chown -R GAME_NAME:GAME_NAME $INSTALL_LOC $CONFIG_LOC
26-
27-
USER GAME_NAME
28-
29-
# REPO_SETUP: You might consider installing steam appid 1007 ("+app_update 1007 validate \")
30-
# REPO_SETUP: alongside your game here if your game needs the steam libraries
31-
# REPO_SETUP: to appear in the server browser etc.
32-
33-
# REPO_SETUP: If your game is windows only, you *might* be able to run it inside a linux container
34-
# REPO_SETUP: with wine and xvfb-run. If so, add a "+@sSteamCmdForcePlatformType windows \"
35-
# REPO_SETUP: line to this steamcmd command, and install xvfb and wine.
36-
# REPO_SETUP: Alternatively, see https://github.com/FragSoc/steamcmd-wine-xvfb-docker;
37-
# REPO_SETUP: you can use this as the base image for this template if you want :)
38-
# REPO_SETUP: (you'll still need that that platform force steamcmd command)
39-
40-
# Install the GAME_NAME server
41-
# REPO_SETUP: Get the appid of the dedicated server from steamdb or similar
42-
ARG APPID=<YOUR APPID HERE>
43-
ARG STEAM_BETA
44-
RUN steamcmd \
45-
+login anonymous \
46-
+force_install_dir $INSTALL_LOC \
47-
+app_update $APPID $STEAM_BETA validate \
48-
+quit && \
49-
# REPO_SETUP: you will probably want to symlink the game's default config directory
50-
# REPO_SETUP: to $CONFIG_LOC here
21+
groupadd -g $GID carriercommand && \
22+
useradd -m -s /bin/false -u $UID -g $GID carriercommand
23+
24+
# Install the carriercommand server
25+
ARG APPID=1489630
26+
ARG STEAM_BETA=""
27+
COPY ./game_files $INSTALL_LOC
28+
COPY ./docker-entrypoint.sh /entrypoint.sh
29+
COPY ./healthcheck.sh /healthcheck.sh
30+
RUN chown -R carriercommand:carriercommand $INSTALL_LOC && \
31+
chmod +x /entrypoint.sh /healthcheck.sh && \
32+
ln -s $CONFIG_LOC/server_config.xml $INSTALL_LOC/server_config.xml
5133

5234
# I/O
53-
VOLUME $CONFIG_LOC
54-
# REPO_SETUP: Add any ports you might need. Don't forget to append with /udp if necessary
35+
VOLUME $CONFIG_LOC $LOG_LOC
36+
# We can't do arithmetic here so the ports are hardcoded :(
37+
EXPOSE 25565/udp 25566/udp 25567/udp
5538

5639
# Expose and run
57-
USER GAME_NAME
40+
USER carriercommand
5841
WORKDIR $INSTALL_LOC
59-
# REPO_SETUP: Add an entrypoint for the game
42+
HEALTHCHECK CMD /healthcheck.sh
43+
ENTRYPOINT ["tini", "--", "/entrypoint.sh"]

Makefile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
STEAM_BETA := ""
2+
STEAM_USERNAME := ""
3+
4+
DOCKER_COMMAND := "docker"
5+
IMAGE_NAME := "fragsoc/carrier-command"
6+
7+
build: game_files
8+
${DOCKER_COMMAND} build -t ${IMAGE_NAME} .
9+
10+
game_files:
11+
steamcmd \
12+
+@sSteamCmdForcePlatformType windows \
13+
+force_install_dir "$(shell pwd -P)/game_files_temp" \
14+
+login $(STEAM_USERNAME) \
15+
+app_update 1489630 ${STEAM_BETA} validate \
16+
+app_update 1007 validate \
17+
+quit
18+
mv ./game_files_temp ./game_files
19+
20+
clean:
21+
rm -rfv ./game_files ./game_files_temp

docker-entrypoint.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
set -eux
3+
4+
xvfb-run -a wine "$INSTALL_LOC/dedicated_server.exe" "$@" \
5+
| tee "$LOG_LOC/$(date +%Y-%m-%d-%H:%M:%S).log"

healthcheck.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
set -eux
3+
4+
LAST_LOG="$(find "$LOGS_LOC" | tail -n 1)"
5+
6+
if [ $(grep -c "connected to Steam" "$LAST_LOG") = 0 ]; then
7+
exit 0
8+
else
9+
exit 1
10+
fi

0 commit comments

Comments
 (0)