Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Complete rework #43

Draft
wants to merge 120 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
7c02ca8
+ dependent dependency installation
jusito Nov 9, 2021
383e4cb
cleanup
jusito Nov 9, 2021
489af8c
added iproute2 to remoive warnings
jusito Nov 10, 2021
594376e
+ multi stage build for better dev experience
jusito Nov 10, 2021
48e8168
+ pr #35 tmux, gamedig, cleanup
jusito Nov 11, 2021
7a6b6ea
+ cron, cleanup
jusito Nov 12, 2021
9afc13d
fix typo
jusito Nov 13, 2021
d315393
fix graceful stop and improved logging
jusito Nov 13, 2021
b85ff2b
prepared health check testing
jusito Nov 14, 2021
ed31da8
fix health check
jusito Nov 14, 2021
2770d07
fix dockerignore
jusito Nov 14, 2021
491fe38
fix log dir permissions
jusito Nov 14, 2021
ccbd495
fix log not existing very early
jusito Nov 14, 2021
c9e454c
+ shellcheck
jusito Nov 15, 2021
c5e120d
+ auto testing every server
jusito Nov 23, 2021
37efa66
~ fix permissions, untested
jusito Nov 23, 2021
043ea82
~ moved results folder
jusito Nov 23, 2021
5ad9527
fix full.sh wait until done
jusito Nov 23, 2021
37b3440
fix empty arguments + tty issues
jusito Nov 24, 2021
7c22f91
fix full.sh docker logs
jusito Nov 24, 2021
50548e8
initial docker image creation automation
jusito Nov 24, 2021
5a27eb8
fix illegal server in list
jusito Nov 24, 2021
3f1bc30
fix healthcheck, improved logging
jusito Nov 24, 2021
e9fa7a9
fix wsl2 != ubuntu
jusito Nov 24, 2021
0601f6a
+ build arg fail early
jusito Nov 24, 2021
87b0c1b
fix build-arg hidden on some systems
jusito Nov 25, 2021
7ed95ed
+ rerun
jusito Nov 25, 2021
d1bbba6
+ feat interuptable testing
jusito Nov 25, 2021
a61dde3
~ changed healthcheck intervall 90 / 75
jusito Nov 25, 2021
5bdae26
fix healthcheck report to early unhealthy
jusito Nov 25, 2021
2eb1507
+ lgsm-load-config
jusito Nov 25, 2021
946bcbe
+ tests + shellcheck fix
jusito Nov 25, 2021
ac5569f
+ testFixPermissions.sh
jusito Nov 26, 2021
d2f5509
+ cleanup testCron
jusito Nov 26, 2021
43cd4ee
+ testUpdateUidGuid.sh
jusito Nov 26, 2021
3670106
fix cron tests
jusito Nov 26, 2021
4a43b32
+ testCron illegal test
jusito Nov 26, 2021
c1bb9f3
+ testLgsmUpdate
jusito Nov 27, 2021
f1631a1
~ cleanup log entries / shellcheck
jusito Nov 27, 2021
6c0aafa
fix test cleanup
jusito Nov 27, 2021
35d9cec
~ mv functions -> features
jusito Nov 27, 2021
02a7c10
fix rename issues
jusito Nov 27, 2021
096ff17
~ test --quick as default
jusito Nov 27, 2021
e693299
+ testLoadConfig
jusito Nov 29, 2021
5302ab1
+ LGSM_DEBUG
jusito Nov 29, 2021
863d8a1
Merge branch 'master' into develop
jusito Nov 29, 2021
bca276b
~ createImages rm existing images before
jusito Nov 29, 2021
8bcfd77
Merge branch 'develop' of https://github.com/GameServerManagers/Linux…
jusito Nov 29, 2021
14b5d40
Merge branch 'GameServerManagers-develop' into develop
jusito Nov 29, 2021
c604896
~ mv github templates
jusito Nov 29, 2021
533a0fd
+ --slow mode for testing
jusito Nov 29, 2021
ef5a26b
+ cleanup
jusito Nov 29, 2021
5283829
+ init dev env script
jusito Nov 29, 2021
f18b62b
+ createImages suffix / help
jusito Nov 29, 2021
0764a24
+ don't invoke full.sh as root
jusito Nov 29, 2021
2301369
+ full.sh printing failed statistics
jusito Nov 29, 2021
9efe374
fix quick as default will to early fail
jusito Nov 29, 2021
95f8871
fix remove anon volumes after
jusito Nov 29, 2021
55742b3
fix --very-fast
jusito Nov 29, 2021
8954237
+ tests print health log
jusito Nov 29, 2021
326e4a6
+ uniform docker layer -> test -> push
jusito Nov 30, 2021
3fbf426
+ chmod +x for files
jusito Dec 1, 2021
1d45b6c
21.04 -> 20.04
jusito Dec 1, 2021
9f0db5e
Merge branch 'develop' of github.com:jusito/LinuxGSM-Docker into develop
jusito Dec 1, 2021
d61b56b
fix line endings
dgibbs64 Dec 2, 2021
02f9a7a
fix steam credentials in log
jusito Feb 10, 2022
1b9b2f5
fix --debug, credentials usage, config load before install
jusito Feb 10, 2022
6ad1ddb
fix empty suffix for tag creation
jusito Feb 10, 2022
2fb23ea
fix empty suffix in run command
jusito Feb 10, 2022
acba19e
cleanup
jusito Feb 10, 2022
1ea92f6
fix whitelist for steam credential usage
jusito Feb 10, 2022
e2b9bfd
+ Flaky Test
jusito Feb 12, 2022
8fa83ef
fix gamedig, nodejs 12+
jusito Feb 12, 2022
b705a7a
fix executable not found
jusito Feb 13, 2022
13cd17b
~ improved dependency installation
jusito Feb 13, 2022
6296020
~ more automated output for tests
jusito Feb 18, 2022
f483d10
~ improved
jusito Feb 20, 2022
ea1015a
fix restart / update exiting container
jusito Feb 21, 2022
2f9f66b
fix gamedig not found
jusito Feb 21, 2022
ce4af3b
fix full.sh not comparing at the end
jusito Feb 21, 2022
b555061
+ clean volume folder
jusito Feb 22, 2022
73ddbcf
update
jusito Feb 26, 2022
fcc5440
fix exit code, dependency installation
jusito Feb 26, 2022
07603af
feat: ubuntu 22.04
jusito Apr 4, 2022
93d0c4f
doc: build arg error message + rustserver compose
jusito Apr 8, 2022
610a1d4
fix: ubuntu 22.04 only set on one stage
jusito Apr 9, 2022
aeb0192
feat: print console.log if initial start fails
jusito Apr 9, 2022
046dbdc
fix: openssl 1.1n missing
jusito Apr 9, 2022
c3660d7
fix: openssl x86 instead of x64 for svenserver
jusito Apr 10, 2022
0d063f4
doc: docker-compose update
jusito Apr 10, 2022
5680475
renaming
jusito Apr 30, 2022
0dce0f0
fix logging
jusito Jun 3, 2022
12aef0a
fix(dependencies): supercronic v0.2.1
jusito Jul 16, 2022
1d0b360
refactor(structure): clear naming
jusito Jul 16, 2022
376e768
doc: preparing docs
jusito Jul 16, 2022
fec88b5
test: debug-utils
jusito Jul 16, 2022
01a0b5d
doc: relocated entrypoint
jusito Jul 16, 2022
4fab05b
doc: renamed scripts
jusito Jul 16, 2022
b270920
doc: general addition
jusito Jul 16, 2022
b655492
test: fix renaming
jusito Jul 16, 2022
20aa66d
fix: nodejs updated
jusito Jul 16, 2022
855b535
doc: compose examples autogenerated
jusito Jul 17, 2022
7bf7379
test: support for setting LGSM_{BRANCH,USER,REPO}
jusito Jul 31, 2022
8e3fff2
doc: how testing works git --git-* args
jusito Jul 31, 2022
b802ef0
fix: openssl1.1 x86 / x64
jusito Jul 31, 2022
77c5872
build: renaming openssl script
jusito Jul 31, 2022
51e7599
fix: openssl 1.1.1n -> 1.1.1q
jusito Jul 31, 2022
64dfcc2
fix: example generation consider credentials
jusito Aug 8, 2022
5627e63
doc: main readme not linking to others
jusito Aug 10, 2022
796c6e8
doc: added docker usage examples
jusito Aug 10, 2022
89d2eec
examples: volumes should contain service name
jusito Aug 11, 2022
7991dee
doc: overview section
jusito Aug 11, 2022
b49970c
clean: fix shellcheck
jusito Aug 12, 2022
75a2d63
test: feature tests added todos
jusito Aug 12, 2022
39859e7
deploy: push.sh wdir not moved
jusito Aug 14, 2022
87ca6ee
test: single.sh changed wdir
jusito Aug 14, 2022
95a6521
test: test scripts shouldn't rely on wdir
jusito Aug 14, 2022
e9af3c3
feat: safer lgsm alias generation + help
jusito Aug 14, 2022
4637629
fix: pinned conan<2.0
jusito Mar 31, 2023
9dcb678
deps: gosu 1.16, ossl 1.1.1t, scron 0.2.2
jusito Mar 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
live/
README.md
test/
.gitignore
.editorconfig
examples/
LICENSE
linuxgsm-docker.sh
*.md

13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs.
# Atom: Please assure your Atom's config setting Tab Type is set to auto, otherwise Atom-EditorConfig may not work as expected. Also disable whitespace package.
# http://editorconfig.org/

root = true

[*]
charset = utf-8
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
*~
test/*results*
**/*.log
test/steam_test_credentials
*.patch
34 changes: 34 additions & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Overview for developers and consumers of the image

If you want to work on this files at all, check/use: `init_dev_environment.sh`. E.g. it will check for tools you need or prevent your steam credentials to be committed

Repository contains:
- docker build scripts `/build`, sometimes usable by extending dockerimages
- runtime scripts `/runtime`, intended to be used by extending dockerimages and available in PATH
- test scripts `/test`

Please check and use its telling you if you need to install tools and prevents commiting your steam credentials by accident.

## features

- lgsm commands are available in PATH so you can directly use them e.g. `lgsm-update` which is the same as `update`
- We are using [Gosu](https://github.com/tianon/gosu) so entrypoint is executed as root but every command is executed with lower user privilege.
- Because the commands take care of gosu, you can use `lgsm-update` in your custom scripts as root and the command will take care of correct user
- Also works if you are using: `docker exec -it CONTAINER update`
- `/runtime` contains scripts(refered to as commands of the image) which provide standard functions, also available in PATH so you can directly invoke them
- `lgsm-fix-permission` resets all file permissions in volume
- `lgsm-update-uid-gid` update uid / gid of lgsm user and all owned files
- `lgsm-init` resets linuxgsm.sh in volume and installs _servercode_.sh
- Cron job handling via Supercronic `lgsm-cron-init` `lgsm-cron-start`
- _alpha state_ `lgsm-load-config` updates gameconfig according to environment variables

## dockerimage folder structure

- `/home/linuxgsm/`
- home folder of linuxgsm user
- volume for linuxgsm installation
- `/home/linuxgsm-scripts`
- contains all scripts and links and is part of PATH variable, so all scripts are directly accessible from everywhere
- initial linuxgsm.sh
- links to lgsm commands like `lgsm-monitor` which is identical to `monitor`

102 changes: 0 additions & 102 deletions Dockerfile

This file was deleted.

86 changes: 57 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,66 @@
A dockerised version of LinuxGSM https://linuxgsm.com
Dockerhub https://hub.docker.com/r/gameservermanagers/linuxgsm-docker/

# How to Use
## How to use:

## Create Persistant Storage
Game servers require persistant storage to store the server files and configs. The docker reccomended way is to use Persistant storage
1. Choose your servercode and replace in below
2. start `docker-compose -f examples/SERVER.yml up -d`, if the server needs credentials there will be placeholders in the compose.
3. get config location `docker exec -it lgsm-SERVER-1 details`
4. copy your own config into: `docker cp my_local_config.txt lgsm-SERVER-1:/config_location_from_step_3`
5. print config content `docker exec lgsm-SERVER-1 cat /config_location_from_step_3`
6. stop with:
- Stopping container and keep files `docker-compose -f examples/SERVER.yml down` or `docker stop lgsm-SERVER-1`
- Stopping container and remove files `docker-compose -f examples/SERVER.yml down --volumes`

```
docker volume create csgoserver
```
## Overview

# Install and Start Game server
```
docker run -d --name csgoserver -v csgoserver --net-host -it -env GAMESERVERNAME=csgoserver gameservermanagers/linuxgsm-docker
```
# Run LinuxGSM commands
Commands can be run just like standard LinuxGSM using the docker exec command.
```
docker exec -it csgoserver ./csgoserver details
```
# Edit LinuxGSM config
To edit the LinuxGSM config files use the following.
- build with `./test/single.sh --build-only servercode`
- test with `./test/single.sh servercode`
- get help `./test/single.sh --help`
- LinuxGSM monitor executed every few seconds as health check
- `docker stop CONTAINER` is redirected to lgsm-stop
- `docker logs CONTAINER` show the game server log
- `docker exec -it CONTAINER --help` every linuxgsm command is available in two forms e.g. `lgsm-update` and `update`. Available commands differ for different servercodes.
- [Repository / Container / Dev structure documentation](DEVELOPER.md)
- [How to build this / How to use it for lgsm testing](test/testing.md)

View the default settings
```
docker exec -it csgoserver nano _default.cfg
```
Edit LinuxGSM config settings
```
docker exec -it csgoserver nano common.cfg
```
Edit Game Server Config settings
To edit the game server config settings run the following.
### How to configure LinuxGSM in docker?

```
docker exec -it csgoserver nano server.cfg
You can configure LinuxGSM and some gameservers(alpha state) with environment variables directly.
E.g. you want to set steamuser / steampass which is a LinuxGSM option:
- `CONFIG_steamuser=...` its checked if this variable exists before its set, container will exit very early if the configuration option isn't already part of _default.cfg
- `CONFIGFORCED_steamuser=...` The variable will be set always, no check done.
- These options will be written to the instance.cfg, thereforce you can use it to set options like `CONFIG_startparameters`, `CONFIG_discordalert` and so on.

### How to use cronjobs?
You can create cron jobs with environment variables. `CRON_update_daily=0 7 * * * update` will create a cronjob which will check for updates once a day.

### Example ahl2server yml:
```yml
volumes:
ahl2server-files:

name: lgsm

services:
ahl2server:
image: "gameservermanagers/linuxgsm-docker:ahl2server"
tty: true
restart: unless-stopped
environment:
- "CRON_update_daily=0 7 * * * update"
- "CONFIGFORCED_steamuser=MySteamName"
- "CONFIGFORCED_steampass=my steam password"
volumes:
- ahl2server-files:/home/linuxgsm
- /etc/localtime:/etc/localtime:ro
ports:
# Game
- "27015:27015/udp"
# Query / RCON
- "27015:27015/tcp"
# SourceTV
- "27020:27020/udp"
# Client
- "27005:27005/udp"
```
87 changes: 87 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# download / build / verify dependencies
# own stage = additional deps needed which are only here used
FROM ubuntu:22.04 as dependencyStage

COPY build/installGosu.sh \
build/installOpenSSL_1.1.sh \
build/installSupercronic.sh \
/
RUN chmod +x installGosu.sh
RUN set -eux; \
./installGosu.sh 1.16; \
./installSupercronic.sh v0.2.2 8c509ffd2f4adfb722e388cc3ad65ac0baf5e69eb472e298144f50303216903d; \
./installOpenSSL_1.1.sh 1.1.1t

# create linuxgsm image
# this stage should be usable by existing developers
FROM ubuntu:22.04 as linuxgsm

ARG ARG_LGSM_VERSION="master"
ENV LGSM_VERSION="${ARG_LGSM_VERSION:?}" \
LGSM_GAMESERVER="" \
LGSM_USE_GAMEDIG="true" \
LGSM_CONFIG_PATTERN_GAME="" \
USER_ID="750" \
GROUP_ID="750" \
LGSM_DEBUG="false" \
\
USER_NAME="linuxgsm" \
LGSM_PATH="/home/linuxgsm" \
LGSM_SCRIPTS="/home/linuxgsm-scripts" \
PATH="$PATH:/home/linuxgsm-scripts/" \
LANG="en_US.UTF-8" \
LANGUAGE="en_US.UTF-8" \
LC_ALL="en_US.UTF-8" \
TERM="xterm" \
SUPERCRONIC_CONFIG="/home/linuxgsm-scripts/cron.config" \
LGSM_STARTED="/home/linuxgsm/server.started" \
LGSM_CURRENT_COMMAND="/home/linuxgsm/lgsm-cmd.currently"

COPY --from=dependencyStage \
/usr/local/bin/gosu \
/usr/local/bin/supercronic \
/usr/local/bin/
COPY --from=dependencyStage \
/usr/local/lib \
/usr/local/lib/
COPY build/installMinimalDependencies.sh \
build/setupUser.sh \
build/installLGSM.sh \
build/installGamedig.sh \
build/cleanImage.sh \
build/installServerDependencies.sh \
build/createAlias.sh \
\
runtime/entrypoint.sh \
runtime/lgsm-cron-init \
runtime/lgsm-cron-start \
runtime/lgsm-init \
runtime/lgsm-fix-permission \
runtime/lgsm-load-config \
runtime/lgsm-tmux-attach \
runtime/lgsm-update-uid-gid \
"$LGSM_SCRIPTS"/

RUN set -eux; \
installMinimalDependencies.sh; \
setupUser.sh; \
installLGSM.sh; \
installGamedig.sh; \
cleanImage.sh

VOLUME "$LGSM_PATH"
WORKDIR "$LGSM_PATH"

# install server specific dependencies
FROM linuxgsm as specific
ARG ARG_LGSM_GAMESERVER=""
ENV LGSM_GAMESERVER="${ARG_LGSM_GAMESERVER:? To build the container by hand you need to set build argument ARG_LGSM_GAMESERVER to your desired servercode}"
RUN set -eux; \
installServerDependencies.sh "$LGSM_GAMESERVER"; \
createAlias.sh "$LGSM_GAMESERVER"; \
cleanImage.sh

HEALTHCHECK --start-period=3600s --interval=90s --timeout=900s --retries=3 \
CMD [ -f "$LGSM_STARTED" ] && lgsm-monitor || exit 1

ENTRYPOINT ["./../linuxgsm-scripts/entrypoint.sh"]
21 changes: 21 additions & 0 deletions build/cleanImage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

# clean/shrink dockerimage and removes unnecessary files
# e.g. remove apt cache and build scripts

set -o errexit
set -o nounset
if "$LGSM_DEBUG"; then
set -o xtrace
fi
echo "[info][cleanImage] cleaning image"

apt-get autoremove -y
apt-get clean -y
rm -rf /var/lib/apt/lists/* >> /dev/null 2>&1 || true
rm -rf "${LGSM_PATH:?}"/* /tmp/* /var/tmp/* || true
rm "$LGSM_SCRIPTS/installMinimalDependencies.sh" \
"$LGSM_SCRIPTS/installLGSM.sh" \
"$LGSM_SCRIPTS/installGamedig.sh" \
"$LGSM_SCRIPTS/setupUser.sh" \
"$LGSM_PATH"/* >> /dev/null 2>&1 || true
Loading