Skip to content

Commit

Permalink
feat: cleanup / add readme file / fix test image script
Browse files Browse the repository at this point in the history
  • Loading branch information
Rouven Himmelstein committed Jan 23, 2024
1 parent 036a995 commit d520c00
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
1 change: 0 additions & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ENV USER_HOME "/home/ubuntu"
ENV STEAMCMD "$USER_HOME/steamcmd/steamcmd.sh"
ENV SERVER_DIR "/data"
ENV SERVER_CONFIG_DIR "/config"
ENV SERVER_CONFIG_FILE "$SERVER_CONFIG_DIR/server.json"

# Use default non root user ubuntu (1000)
WORKDIR $USER_HOME
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Sons of the Forest dedicated server container image

24 changes: 14 additions & 10 deletions test-image.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
#!/usr/bin/env bash

# Create config and data directories, ignore errors if they already exist
mkdir -p ./config ./data 2> /dev/null

# Spin up a new container
echo "🚀 Spinning up a test container"
docker run -d --name test-container rouhim/sons-of-the-forest
docker-compose up -d

# Wait some time
echo "😴 sleeping 10 minutes"
sleep 10m

# Test for "[Self-Tests] Please restart the server"
# Test for the string "Please restart the server" is in the server log
# If it is, then the server started successfully
# If it is not, then the server failed to start
echo "🧪 Testing for success"
docker logs test-container | grep -i '\[Self-Tests\] Please restart the server'
if [ "$?" -eq 0 ]; then
echo "❌ Found errors in server log:"
echo "======================"
docker logs test-container
echo "======================"
docker kill test-container && docker rm test-container
if docker-compose logs | grep -q "Please restart the server"; then
echo "✅ Server started successfully"
else
echo "❌ Server failed to start"
docker-compose logs
docker-compose kill && docker-compose down --volumes
exit 1
fi

# Cleanup and exit with 0
docker kill test-container && docker rm test-container
docker-compose kill && docker-compose down --volumes
echo "✅ Done, everything looks good"
exit 0

0 comments on commit d520c00

Please sign in to comment.