Use more env vars

Update README.md
Remove makefile
This commit is contained in:
Ari Timonen 2020-04-05 17:22:37 +03:00 committed by Jiriki
parent b119ee9593
commit 22d727d33c
7 changed files with 96 additions and 72 deletions

11
.env.default Normal file
View file

@ -0,0 +1,11 @@
# Copy this file to .env to change settings. Load it before docker-compose
# CMD line options
HLDS_OPTS=-game ns +maxplayers 32 +log on +map ns_veil +exec ns/server.cfg -port 27016 -pingboost 3 +sys_ticrate 1000
HLTV_OPTS=+serverpassword europe +connect hlds:27016 +record demos/gathers
# Set this to 1 to enable fps recording
HLDS_RECORD_FPS=0
RCON_HOST=localhost
RCON_PORT=27016
RCON_PASSWORD=cbfkgRSK0RrvJzQ

View file

@ -3,16 +3,20 @@ FROM ubuntu AS Ubuntu_SteamCMD
# Get Package Dependencies, Accept ToS with Steam Dependency, clear appt cache
RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get -y install wget \
apt-get -y install \
wget \
lib32gcc1 \
lib32stdc++6 \
libstdc++6:i386 \
libcurl3:i386 \
gcc-multilib \
g++-multilib \
unzip \
liblz4-tool \
gcc-multilib \
g++-multilib && \
printf "\n2\n"|apt-get install -y steamcmd && \
# Fro env subst
gettext-base && \
# Install steam
printf "\n2\n" |apt-get install -y steamcmd && \
rm -rf /var/lib/apt/lists/*
RUN useradd -m steam
@ -30,7 +34,7 @@ RUN /usr/games/steamcmd +login anonymous +force_install_dir /home/steam/hlds +ap
# HLDS bug workaround. Whee.
COPY --chown=steam files/*.acf /home/steam/hlds/steamapps/
# HLDS bug workaround. Geez.
# HLDS bug workaround. Geez.
RUN printf "quit\nquit\n"|/usr/games/steamcmd +login anonymous +force_install_dir /home/steam/hlds +app_set_config 90 mod valve +app_update 90 validate ||true && \
printf "quit\nquit\n"|/usr/games/steamcmd +login anonymous +force_install_dir /home/steam/hlds +app_set_config 90 mod valve +app_update 90 validate ||true && \
printf "quit\nquit\nquit\nquit\nquit\n" |/usr/games/steamcmd +login anonymous +force_install_dir /home/steam/hlds +app_set_config 90 mod valve +app_update 90 validate ||true
@ -42,22 +46,27 @@ COPY scripts/*.sh /home/steam/hlds/
FROM SteamCMD_HLDS AS HLDS_NS
ARG NS_URL='https://github.com/ENSL/NS/releases/download/v3.2.2/ns_v322_full.zip'
WORKDIR /home/steam/hlds
COPY --chown=steam files/ns.sha /home/steam/hlds
# NS bug workaround. Since NS links to a GCC which is not included in the steam-provided libstdc++:i386
RUN mv /home/steam/hlds/libstdc++* /home/steam/ && \
# Install NS
wget 'https://github.com/ENSL/NS/releases/download/v3.2.2/ns_v322_full.zip' && \
unzip ns_v322_full.zip && \
wget "$NS_URL" && \
unzip ns_*.zip && \
cp /home/steam/hlds/ns/liblist.gam /home/steam/hlds/ns/liblist.bak
FROM HLDS_NS AS HLDS_ENSL
ARG PLUGIN_URL='https://github.com/ENSL/ensl-plugin/releases/download/1.4-extra/ENSL_SrvPkg-1.4-extra.zip'
WORKDIR /home/steam/hlds/ns
# ENSL package
RUN wget https://github.com/ENSL/ensl-plugin/releases/download/1.4-extra/ENSL_SrvPkg-1.4-extra.zip -O srv.zip && \
RUN wget "$PLUGIN_URL" -O srv.zip && \
unzip -o srv.zip && \
# Use seperate server.cfg because autoexec.cfg is unreliable
touch /home/steam/hlds/ns/server.cfg

View file

@ -1,45 +0,0 @@
REGISTRY ?= ensl
PROJECT ?= ensl_hlds
TAG ?= latest
.PHONY: all clean build stop run pull push
ifdef REGISTRY
IMAGE=$(REGISTRY)/$(PROJECT):$(TAG)
else
IMAGE=$(PROJECT):$(TAG)
endif
all:
@echo "Available targets:"
@echo " * build - build a Docker image for $(IMAGE)"
@echo " * pull - pull $(IMAGE)"
@echo " * push - push $(IMAGE)"
@echo " * test - build and test $(IMAGE)"
build: Dockerfile
docker build -t $(IMAGE) .
run: build
mkdir -p logs
#docker run -p 27015:27015 27015/udp:27015/udp -v $(shell pwd)/logs:/home/steam/hlds/ns/logs -ti $(IMAGE)
# docker run --name=$(PROJECT) --net=host -v $(shell pwd)/logs:/home/steam/hlds/ns/logs -ti $(IMAGE)
docker run -e HLDS='1' --name=$(PROJECT) --net=host -v $(shell pwd)/logs:/home/steam/hlds/ns/logs -ti $(IMAGE)
stop:
docker stop $(PROJECT)
docker rm $(PROJECT)
shell:
docker exec -u0 -ti $(PROJECT) /bin/bash
# docker run --name=$(PROJECT) --net=host -v $(shell pwd)/logs:/home/steam/hlds/ns/logs -u0 -ti $(IMAGE) /bin/bash
pull:
docker pull $(IMAGE) || true
push:
docker push $(IMAGE)
clean:
docker ps -a | awk '{ print $$1,$$2 }' | grep $(IMAGE) |awk '{print $$1 }' |xargs -I {} docker rm {}
docker images -a |grep $(IMAGE) |awk '{print $$3}' |xargs -I {} docker rmi {}

View file

@ -1,16 +1,42 @@
# ENSL HLDS Dockerfile.
# ENSL HLDS Docker container.
This repo is totally Work In Progress. I just dumped it here so others can benefit. Will be polished some beatiful day.
This repo is totally Work In Progress. I just put it here so others can benefit. Will be polished some nice day.
How to use:
* `make build` to build Docker image
* `make run` to start NS1 server at default port on localhost
* `make stop` to stop the NS1 server
* `make clean` to clean containers and images
## Setup
Add any custom configs you want to to overlay directory.
1. Add any custom configs or plugins you want to to overlay directory.
1. If you need to change env. variables, copy `.env.default` to `.env` and change it.
### How to start:
docker-compose up --build
### How to attach to console (replace CONTAINER_NAME with hlds or hltv):
docker attach CONTAINER_NAME
### How to run shell in container:
docker-compose exec CONTAINER_NAME /bin/bash
### How to stop:
docker-compose down
## Other things
1. Demos and logs are found in demos and logs folder. If you get any permission errors run in repo root directory
sudo chown -R 1000:100 demos logs
1. Run following command to renice the servers to maximum priority.
bash ./scripts/renice.sh
1. ~~You can enable FPS record with HLDS_RECORD_FPS=1 in `.env`~~
## Features
Features:
* Basically installs HLDS + NS1 server + ENSL Plugin.
* Also adds log compression with LZ4.
* Optional argument to enable HLTV.
* Optional argument to enable HLTV.

View file

@ -3,37 +3,55 @@ version: "3.0"
services:
hlds:
image: ensl/ensl_hlds:latest
build:
context: ./
dockerfile: Dockerfile
container_name: "ensl_hlds"
# user: "${UID}:${GID}"
volumes:
- "./logs:/home/steam/hlds/ns/logs"
network_mode: "ensl_hlds_default"
ports:
- 26900:26900
- 27016:27016/udp
- 27016:27016
- 27016:27016/udp
environment:
- HLDS=1
env_file:
- '.env.default'
hltv:
image: ensl/ensl_hlds:latest
build:
context: ./
dockerfile: Dockerfile
container_name: "ensl_hltv"
# user: "${UID}:${GID}"
volumes:
- "./demos:/home/steam/hlds/ns/demos"
network_mode: "ensl_hlds_default"
depends_on:
- hlds
ports:
- 27020:27020
environment:
- HLTV=1
env_file:
- '.env.default'
cleaner:
image: ensl/ensl_hlds:latest
build:
context: ./
dockerfile: Dockerfile
container_name: "ensl_cleaner"
# user: "${UID}:${GID}"
volumes:
- "./demos:/home/steam/hlds/ns/demos"
- "./logs:/home/steam/hlds/ns/logs"
network_mode: "ensl_hlds_default"
depends_on:
- hlds
- hltv
environment:
- HLDS_ROTATE=1
- HLTV_ROTATE=1
env_file:
- '.env.default'

View file

@ -1,6 +1,6 @@
// General settings
hostname "Natural Selection v3.2.1b"
hostname "Natural Selection v3.2.2"
mp_autoconcede 4
mp_blockscripts 0
mp_combattime 15

View file

@ -17,14 +17,19 @@ if [[ "$HLTV_ROTATE" = "1" ]]; then
fi
if [[ "$HLTV" = "1" ]]; then
echo "Starting HLTV localhost:27016"
echo "Starting HLTV"
sleep 10
export LD_LIBRARY_PATH=.
./hltv +serverpassword europe +connect localhost:27016 +record demos/gathers >> /home/steam/hlds/ns/demos/hltv-`date +%F-%h:%m`.log
set -o xtrace
./hltv $HLTV_OPTS >> /home/steam/hltv-`date +%F-%h:%m`.log
set +o xtrace
echo "Started"
elif [[ "$HLDS" = "1" ]]; then
echo "Starting HLDS -port 27016"
echo "Starting HLDS"
set -o xtrace
export LD_LIBRARY_PATH=.
./hlds_run -game ns +maxplayers 32 +log on +map ns_veil +exec ns/server.cfg -port 27016 -pingboost 3 +sys_ticrate 1000
./hlds_run $HLDS_OPTS
set +o xtrace
echo "Started"
fi