mapcycle and all
This commit is contained in:
parent
bcf798a5f9
commit
1528f0a2b0
2
.env
2
.env
@ -5,7 +5,7 @@ SRCDS_TOKEN=C02633B3395EA6BEF7D8DFBA440ABB7F
|
|||||||
SRCDS_RCONPW="reebok"
|
SRCDS_RCONPW="reebok"
|
||||||
SRCDS_PW="6"
|
SRCDS_PW="6"
|
||||||
|
|
||||||
SRCDS_STARTMAP="surf_boreas"
|
SRCDS_STARTMAP="surf_fornax"
|
||||||
SRCDS_HOSTNAME="megastructure surf"
|
SRCDS_HOSTNAME="megastructure surf"
|
||||||
SRCDS_MAXPLAYERS=16
|
SRCDS_MAXPLAYERS=16
|
||||||
|
|
||||||
|
|||||||
46
Justfile
46
Justfile
@ -1,21 +1,3 @@
|
|||||||
build-css:
|
|
||||||
docker build -f css/css.dockerfile css/ -t megastructure/css
|
|
||||||
|
|
||||||
up:
|
|
||||||
docker compose up --remove-orphans
|
|
||||||
|
|
||||||
down:
|
|
||||||
docker compose down -v --remove-orphans
|
|
||||||
|
|
||||||
build:
|
|
||||||
docker compose build
|
|
||||||
|
|
||||||
cssds-run:
|
|
||||||
docker compose run -u root -it cssds bash
|
|
||||||
|
|
||||||
cssds-exec:
|
|
||||||
docker compose exec -u root -it cssds bash
|
|
||||||
|
|
||||||
# Map downloader commands
|
# Map downloader commands
|
||||||
mapsdl-dry:
|
mapsdl-dry:
|
||||||
cd src/mapsdl && deno run -A mapsdl.ts --dry-run
|
cd src/mapsdl && deno run -A mapsdl.ts --dry-run
|
||||||
@ -28,3 +10,31 @@ mapsdl-all-dry:
|
|||||||
|
|
||||||
mapsdl-all:
|
mapsdl-all:
|
||||||
cd src/mapsdl && deno run -A mapsdl-all.ts --dry-run
|
cd src/mapsdl && deno run -A mapsdl-all.ts --dry-run
|
||||||
|
|
||||||
|
# k8s
|
||||||
|
build:
|
||||||
|
docker build -t megastructure-surf-cssds:local -t registry.ntwl.xyz/megastructure-surf-cssds src/cssds
|
||||||
|
docker build -t megastructure-surf-mapsdl:local -t registry.ntwl.xyz/megastructure-surf-mapsdl src/mapsdl
|
||||||
|
docker build -t megastructure-surf-fastdl:local -t registry.ntwl.xyz/megastructure-surf-fastdl src/fastdl
|
||||||
|
|
||||||
|
push:
|
||||||
|
docker push registry.ntwl.xyz/megastructure-surf-cssds
|
||||||
|
docker push registry.ntwl.xyz/megastructure-surf-mapsdl
|
||||||
|
docker push registry.ntwl.xyz/megastructure-surf-fastdl
|
||||||
|
|
||||||
|
build-cssds:
|
||||||
|
docker build -t megastructure-surf-cssds:local -t registry.ntwl.xyz/megastructure-surf-cssds src/cssds
|
||||||
|
|
||||||
|
build-mapsdl:
|
||||||
|
docker build -t megastructure-surf-mapsdl:local -t registry.ntwl.xyz/megastructure-surf-mapsdl src/mapsdl
|
||||||
|
|
||||||
|
build-fastdl:
|
||||||
|
docker build -t megastructure-surf-fastdl:local -t registry.ntwl.xyz/megastructure-surf-fastdl src/fastdl
|
||||||
|
|
||||||
|
apply:
|
||||||
|
kubectl delete pod mapsdl -n surf --ignore-not-found
|
||||||
|
kubectl apply -f k8s.yaml
|
||||||
|
|
||||||
|
env:
|
||||||
|
kubectl delete secret surf -n surf --ignore-not-found
|
||||||
|
kubectl create secret generic surf --from-env-file=.env -n surf
|
||||||
|
|||||||
@ -1,75 +0,0 @@
|
|||||||
services:
|
|
||||||
cssds:
|
|
||||||
image: registry.ntwl.xyz/megastructure-surf
|
|
||||||
|
|
||||||
build:
|
|
||||||
dockerfile: cssds.dockerfile
|
|
||||||
context: ./etc
|
|
||||||
|
|
||||||
user: "1000:1000"
|
|
||||||
|
|
||||||
env_file:
|
|
||||||
- .env
|
|
||||||
|
|
||||||
# command: sleep 5000000
|
|
||||||
|
|
||||||
network_mode: host
|
|
||||||
|
|
||||||
ports:
|
|
||||||
- "27015:27015"
|
|
||||||
- "27015:27015/udp"
|
|
||||||
- "27020:27020"
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- ./etc:/home/steam/etc
|
|
||||||
- ./data/cssds:/home/steam/cssds
|
|
||||||
- tf2ds:/home/steam/tf2ds
|
|
||||||
- fastdl-maps:/fastdl/maps:ro
|
|
||||||
|
|
||||||
db:
|
|
||||||
image: mariadb:12
|
|
||||||
restart: always
|
|
||||||
ports:
|
|
||||||
- "3306:3306"
|
|
||||||
env_file:
|
|
||||||
- .env
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- ./etc/mariadb/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
|
|
||||||
|
|
||||||
mapsdl:
|
|
||||||
image: registry.ntwl.xyz/megastructure-surf-mapsdl
|
|
||||||
|
|
||||||
build:
|
|
||||||
context: ./src/mapsdl
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
# Mount credentials (read-only)
|
|
||||||
- ./src/mapsdl/credentials:/app/credentials:ro
|
|
||||||
|
|
||||||
# Output bz2 files to shared FastDL volume
|
|
||||||
- fastdl-maps:/maps
|
|
||||||
|
|
||||||
environment:
|
|
||||||
- MAPS_DIR=/maps
|
|
||||||
- TEMP_DIR=/tmp/mapsdl
|
|
||||||
- GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/service-account.json
|
|
||||||
|
|
||||||
# Don't start automatically with docker-compose up
|
|
||||||
profiles:
|
|
||||||
- tools
|
|
||||||
|
|
||||||
# Run once and exit
|
|
||||||
restart: "no"
|
|
||||||
|
|
||||||
fastdl:
|
|
||||||
build: ./src/fastdl
|
|
||||||
ports:
|
|
||||||
- "8080:80"
|
|
||||||
volumes:
|
|
||||||
- fastdl-maps:/srv/maps:ro
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
tf2ds:
|
|
||||||
fastdl-maps:
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
FROM cm2network/steamcmd AS build
|
|
||||||
LABEL maintainer="ntr@megastructure.games"
|
|
||||||
|
|
||||||
EXPOSE 27015/tcp \
|
|
||||||
27015/udp \
|
|
||||||
27020/udp
|
|
||||||
|
|
||||||
USER root
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get install -y \
|
|
||||||
wget \
|
|
||||||
ca-certificates \
|
|
||||||
zlib1g \
|
|
||||||
lib32gcc-s1 \
|
|
||||||
libncurses5 \
|
|
||||||
libbz2-1.0 \
|
|
||||||
libtinfo5 \
|
|
||||||
libcurl3-gnutls \
|
|
||||||
unzip \
|
|
||||||
rcon
|
|
||||||
|
|
||||||
ENV CSSDS="/home/steam/cssds"
|
|
||||||
ENV TF2DS="/home/steam/tf2ds"
|
|
||||||
ENV STEAMCMD="/home/steam/steamcmd"
|
|
||||||
ENV ETC="/home/steam/etc"
|
|
||||||
ENV METAMOD_VERSION=1.12
|
|
||||||
ENV SOURCEMOD_VERSION=1.12
|
|
||||||
|
|
||||||
# ensure gamedirs exist and have been chowned to steam
|
|
||||||
# before they potentially get setup as docker volumes
|
|
||||||
# which would otherwise cause them to be owned by root
|
|
||||||
RUN mkdir -p "$CSSDS" "$TF2DS" "$STEAMCMD" "$ETC"
|
|
||||||
RUN chown -R steam:steam /home/steam
|
|
||||||
|
|
||||||
FROM build AS steam
|
|
||||||
|
|
||||||
USER steam
|
|
||||||
WORKDIR /home/steam
|
|
||||||
|
|
||||||
COPY . /home/steam/etc
|
|
||||||
CMD ["bash", "./etc/run.sh"]
|
|
||||||
275
k8s.yaml
Normal file
275
k8s.yaml
Normal file
@ -0,0 +1,275 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: surf
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# VOLUMES
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: cssds-data
|
||||||
|
namespace: surf
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: fastdl-maps
|
||||||
|
namespace: surf
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 5Gi
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# ENV (create/update with: just env)
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# CSSDS
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: cfg
|
||||||
|
namespace: surf
|
||||||
|
data:
|
||||||
|
mapcycle.txt: |
|
||||||
|
surf_anzchamps
|
||||||
|
surf_boreas
|
||||||
|
surf_deathstar
|
||||||
|
surf_ebony
|
||||||
|
surf_fornax
|
||||||
|
surf_garden
|
||||||
|
surf_in_space
|
||||||
|
surf_kepler
|
||||||
|
surf_kitsune
|
||||||
|
surf_kitsune2
|
||||||
|
surf_lt_omnific
|
||||||
|
surf_pantheon
|
||||||
|
surf_utopia_njv
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: cssds
|
||||||
|
namespace: surf
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: cssds
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: cssds
|
||||||
|
spec:
|
||||||
|
securityContext:
|
||||||
|
runAsUser: 1000
|
||||||
|
runAsGroup: 1000
|
||||||
|
fsGroup: 1000
|
||||||
|
initContainers:
|
||||||
|
- name: fix-permissions
|
||||||
|
image: busybox
|
||||||
|
securityContext:
|
||||||
|
runAsUser: 0
|
||||||
|
command: ['sh', '-c', 'chown -R 1000:1000 /home/steam/cssds']
|
||||||
|
volumeMounts:
|
||||||
|
- name: cssds-data
|
||||||
|
mountPath: /home/steam/cssds
|
||||||
|
containers:
|
||||||
|
- name: cssds
|
||||||
|
image: megastructure-surf-cssds:local
|
||||||
|
imagePullPolicy: Never
|
||||||
|
ports:
|
||||||
|
- containerPort: 27015
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 27015
|
||||||
|
protocol: UDP
|
||||||
|
- containerPort: 27020
|
||||||
|
protocol: UDP
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: surf
|
||||||
|
volumeMounts:
|
||||||
|
- name: src
|
||||||
|
mountPath: /home/steam/src
|
||||||
|
- name: cssds-data
|
||||||
|
mountPath: /home/steam/cssds
|
||||||
|
- name: fastdl-maps
|
||||||
|
mountPath: /fastdl/maps
|
||||||
|
readOnly: true
|
||||||
|
- name: cfg
|
||||||
|
mountPath: /home/steam/cfg
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
- name: src
|
||||||
|
hostPath:
|
||||||
|
path: /run/desktop/mnt/host/c/Users/ntr/code/surf_megastructure/src/cssds
|
||||||
|
- name: cssds-data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: cssds-data
|
||||||
|
- name: fastdl-maps
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: fastdl-maps
|
||||||
|
- name: cfg
|
||||||
|
configMap:
|
||||||
|
name: cfg
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: cssds
|
||||||
|
namespace: surf
|
||||||
|
spec:
|
||||||
|
type: LoadBalancer
|
||||||
|
selector:
|
||||||
|
app: cssds
|
||||||
|
ports:
|
||||||
|
- name: game-tcp
|
||||||
|
protocol: TCP
|
||||||
|
port: 27015
|
||||||
|
targetPort: 27015
|
||||||
|
- name: game-udp
|
||||||
|
protocol: UDP
|
||||||
|
port: 27015
|
||||||
|
targetPort: 27015
|
||||||
|
- name: tv
|
||||||
|
protocol: UDP
|
||||||
|
port: 27020
|
||||||
|
targetPort: 27020
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# FASTDL
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: fastdl
|
||||||
|
namespace: surf
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: fastdl
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: fastdl
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: fastdl
|
||||||
|
image: megastructure-surf-fastdl:local
|
||||||
|
imagePullPolicy: Never
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
volumeMounts:
|
||||||
|
- name: fastdl-maps
|
||||||
|
mountPath: /srv/maps
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
- name: fastdl-maps
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: fastdl-maps
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: fastdl
|
||||||
|
namespace: surf
|
||||||
|
spec:
|
||||||
|
type: LoadBalancer
|
||||||
|
selector:
|
||||||
|
app: fastdl
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 8080
|
||||||
|
targetPort: 80
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# MAP DOWNLOADER (run manually: kubectl apply, then delete when done)
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: mapsdl
|
||||||
|
namespace: surf
|
||||||
|
spec:
|
||||||
|
restartPolicy: Never
|
||||||
|
securityContext:
|
||||||
|
runAsUser: 1000
|
||||||
|
runAsGroup: 1000
|
||||||
|
fsGroup: 1000
|
||||||
|
containers:
|
||||||
|
- name: mapsdl
|
||||||
|
image: megastructure-surf-mapsdl:local
|
||||||
|
imagePullPolicy: Never
|
||||||
|
command: ["deno", "run", "-A", "mapsdl.ts"]
|
||||||
|
env:
|
||||||
|
- name: MAPS_DIR
|
||||||
|
value: "/maps"
|
||||||
|
- name: TEMP_DIR
|
||||||
|
value: "/tmp/mapsdl"
|
||||||
|
- name: GOOGLE_APPLICATION_CREDENTIALS
|
||||||
|
value: "/app/credentials/service-account.json"
|
||||||
|
- name: MAPS_WISHLIST
|
||||||
|
value: |
|
||||||
|
surf_anzchamps
|
||||||
|
surf_boreas
|
||||||
|
surf_deathstar
|
||||||
|
surf_ebony
|
||||||
|
surf_fornax
|
||||||
|
surf_garden
|
||||||
|
surf_in_space
|
||||||
|
surf_kepler
|
||||||
|
surf_kitsune
|
||||||
|
surf_kitsune2
|
||||||
|
surf_lt_omnific
|
||||||
|
surf_pantheon
|
||||||
|
surf_utopia_njv
|
||||||
|
volumeMounts:
|
||||||
|
- name: fastdl-maps
|
||||||
|
mountPath: /maps
|
||||||
|
- name: credentials
|
||||||
|
mountPath: /app/credentials
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
- name: fastdl-maps
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: fastdl-maps
|
||||||
|
- name: credentials
|
||||||
|
hostPath:
|
||||||
|
path: /run/desktop/mnt/host/c/Users/ntr/code/surf_megastructure/src/mapsdl/credentials
|
||||||
|
|
||||||
|
---
|
||||||
@ -27,14 +27,14 @@ RUN apt-get update && apt-get install -y \
|
|||||||
|
|
||||||
ENV CSSDS="/home/steam/cssds"
|
ENV CSSDS="/home/steam/cssds"
|
||||||
ENV STEAMCMD="/home/steam/steamcmd"
|
ENV STEAMCMD="/home/steam/steamcmd"
|
||||||
ENV ETC="/home/steam/etc"
|
ENV SRC="/home/steam/src"
|
||||||
ENV METAMOD_VERSION=1.12
|
ENV METAMOD_VERSION=1.12
|
||||||
ENV SOURCEMOD_VERSION=1.12
|
ENV SOURCEMOD_VERSION=1.12
|
||||||
|
|
||||||
# ensure gamedirs exist and have been chowned to steam
|
# ensure gamedirs exist and have been chowned to steam
|
||||||
# before they potentially get setup as docker volumes
|
# before they potentially get setup as docker volumes
|
||||||
# which would otherwise cause them to be owned by root
|
# which would otherwise cause them to be owned by root
|
||||||
RUN mkdir -p "$CSSDS" "$STEAMCMD" "$ETC"
|
RUN mkdir -p "$CSSDS" "$STEAMCMD" "$SRC"
|
||||||
RUN chown -R steam:steam /home/steam
|
RUN chown -R steam:steam /home/steam
|
||||||
|
|
||||||
FROM build AS steam
|
FROM build AS steam
|
||||||
@ -42,5 +42,5 @@ FROM build AS steam
|
|||||||
USER steam
|
USER steam
|
||||||
WORKDIR /home/steam
|
WORKDIR /home/steam
|
||||||
|
|
||||||
COPY . /home/steam/etc
|
COPY . /home/steam/src
|
||||||
CMD ["bash", "./etc/run.sh"]
|
CMD ["bash", "./src/run.sh"]
|
||||||
@ -1 +1,2 @@
|
|||||||
|
surf_fornax
|
||||||
surf_boreas
|
surf_boreas
|
||||||
@ -1,6 +1,6 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
set -uxe
|
set -ue
|
||||||
|
|
||||||
# Parse command-line flags
|
# Parse command-line flags
|
||||||
# By default, skip updates (set to 1)
|
# By default, skip updates (set to 1)
|
||||||
@ -39,7 +39,7 @@ update_cssds() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
cd $STEAMCMD
|
cd $STEAMCMD
|
||||||
./steamcmd.sh +runscript "$HOME/etc/update_cssds.txt"
|
./steamcmd.sh +runscript "$HOME/src/update_cssds.txt"
|
||||||
|
|
||||||
echo "--------------------------------------------------------------"
|
echo "--------------------------------------------------------------"
|
||||||
echo "CSS DS is up to date"
|
echo "CSS DS is up to date"
|
||||||
@ -450,8 +450,8 @@ EOF
|
|||||||
|
|
||||||
cfg() {
|
cfg() {
|
||||||
cd
|
cd
|
||||||
cp etc/cfg/server.cfg cssds/cstrike/cfg/
|
cp src/cfg/server.cfg cssds/cstrike/cfg/
|
||||||
cp etc/cfg/mapcycle.txt cssds/cstrike/cfg/
|
cp cfg/mapcycle.txt cssds/cstrike/cfg/
|
||||||
sed -i "s|sv_downloadurl .*|sv_downloadurl \"${FASTDL_URL:-}/cstrike/\"|" "$CSTRIKE/cfg/server.cfg"
|
sed -i "s|sv_downloadurl .*|sv_downloadurl \"${FASTDL_URL:-}/cstrike/\"|" "$CSTRIKE/cfg/server.cfg"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,13 +504,17 @@ populate_maps() {
|
|||||||
|
|
||||||
|
|
||||||
run_cssds() {
|
run_cssds() {
|
||||||
echo "ready to run"
|
|
||||||
cd "$CSSDS"
|
cd "$CSSDS"
|
||||||
|
|
||||||
|
local startmap="${SRCDS_STARTMAP:-}"
|
||||||
|
if [ -z "$startmap" ]; then
|
||||||
|
startmap=$(grep -v '^\s*\/\/' "$CSTRIKE/cfg/mapcycle.txt" | grep -m1 '\S')
|
||||||
|
fi
|
||||||
|
|
||||||
./srcds_run -game cstrike \
|
./srcds_run -game cstrike \
|
||||||
-port "${SRCDS_PORT}" \
|
-port "${SRCDS_PORT}" \
|
||||||
+maxplayers "${SRCDS_MAXPLAYERS}" \
|
+maxplayers "${SRCDS_MAXPLAYERS}" \
|
||||||
+map "${SRCDS_STARTMAP}" \
|
+map "$startmap" \
|
||||||
-ip "${SRCDS_IP}"
|
-ip "${SRCDS_IP}"
|
||||||
}
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user