From 5060c85fd8d13d672c6448a2bb64771815fb4769 Mon Sep 17 00:00:00 2001 From: Vintric Date: Fri, 13 Oct 2023 12:11:40 +0200 Subject: [PATCH] Initial version --- .README | 27 +++++++++++++++ docker-compose.yml | 60 +++++++++++++++++++++++++++++++++ ebotlogreceiver/Dockerfile | 15 +++++++++ ebotsocket/Dockerfile | 9 +++++ ebotsocket/setup.sh | 29 ++++++++++++++++ ebotweb/Dockerfile | 17 ++++++++++ ebotweb/setup.sh | 32 ++++++++++++++++++ etc/eBotLogReceiver/config.json | 45 +++++++++++++++++++++++++ etc/eBotSocket/config.ini | 60 +++++++++++++++++++++++++++++++++ etc/eBotWeb/app_user.yml | 36 ++++++++++++++++++++ etc/eBotWeb/databases.yml | 10 ++++++ etc/nginx/default.conf | 34 +++++++++++++++++++ 12 files changed, 374 insertions(+) create mode 100644 .README create mode 100644 docker-compose.yml create mode 100644 ebotlogreceiver/Dockerfile create mode 100644 ebotsocket/Dockerfile create mode 100644 ebotsocket/setup.sh create mode 100644 ebotweb/Dockerfile create mode 100644 ebotweb/setup.sh create mode 100644 etc/eBotLogReceiver/config.json create mode 100644 etc/eBotSocket/config.ini create mode 100644 etc/eBotWeb/app_user.yml create mode 100644 etc/eBotWeb/databases.yml create mode 100644 etc/nginx/default.conf diff --git a/.README b/.README new file mode 100644 index 0000000..b08f241 --- /dev/null +++ b/.README @@ -0,0 +1,27 @@ +# eBot Docker + +## Overview +It is a containerized version of eBot, which is a full managed server-bot written in PHP and nodeJS. eBot features easy match creation and tons of player and matchstats. Once it's setup, using the eBot is simple and fast. + +## How to run it +You should download the repository content, place it in a folder, and then execute the following commands in the specified order: +``` +docker-compose build +docker-compose up +``` + +## What needs to be changed +To ensure everything works correctly, you must configure the external addresses for the web and socket services. + +### Web +To configure the web service, navigate to etc/eBotWeb and update the ebot_ip property with your external address. + +## Socket +To configure the socket service, go to etc/eBotSocket and update the LOG_ADDRESS_SERVER property with your external address. + +## Security +To improve security, you should set the web socket secret key in two specific configuration files: + +For the web service, go the etc/eBotWeb directory and open the app_user.yml file. Inside this file, locate the WEBSOCKET_SECRET_KEY parameter and replace its value with a strong and unique secret key + +For the socket service, navigate to the etc/eBotSocket directory and open the config.ini file. Within this file, find the websocket_secret_key property and update its value with the same key used for the web service. \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..bc667d4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,60 @@ +version: '3' +services: + ebotweb: + build: + context: ./ebotweb + volumes: + - "eBotWebVolume:/app/eBot-CSGO-Web" + - "./etc/eBotWeb/app_user.yml:/app/eBot-CSGO-Web/config/app_user.yml" + - "./etc/eBotWeb/databases.yml:/app/eBot-CSGO-Web/config/databases.yml" + depends_on: + - mysqldb + ebotsocket: + build: + context: ./ebotsocket + ports: + - "12360:12360" + volumes: + - "./etc/eBotSocket/config.ini:/app/eBot-CSGO/config/config.ini" + depends_on: + - mysqldb + - ebotweb + - redis + ebotlogreceiver: + build: + context: ./ebotlogreceiver + ports: + - "12345:12345" + volumes: + - "./etc/eBotLogReceiver/config.json:/app/ebot-project/configs/config.json" + depends_on: + - redis + mysqldb: + image: biarms/mysql:5.7 + restart: always + environment: + - MYSQL_DATABASE=ebotv3 + - MYSQL_ROOT_PASSWORD=7w£6GfV0z92 + - MYSQL_USER=ebotv3 + - MYSQL_PASSWORD=7w£6GfV0z92 + volumes: + - "./data/db/mysql:/var/lib/mysql" + redis: + image: redis:alpine + restart: always + volumes: + - ./data/redis:/data + nginx: + image: nginx:alpine + volumes: + - "./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf" + - "eBotWebVolume:/app/eBot-CSGO-Web" + ports: + - "80:80" + - "443:443" + restart: always + depends_on: + - ebotweb + - mysqldb +volumes: + eBotWebVolume: diff --git a/ebotlogreceiver/Dockerfile b/ebotlogreceiver/Dockerfile new file mode 100644 index 0000000..8b1d5c2 --- /dev/null +++ b/ebotlogreceiver/Dockerfile @@ -0,0 +1,15 @@ +FROM node:18 + +RUN apt-get update && apt-get install -y --force-yes git && apt-get clean + +RUN npm install -g typescript ts-node + +WORKDIR /app + +RUN git clone https://github.com/deStrO/ebot-project.git + +WORKDIR /app/ebot-project + +RUN npm install + +CMD ["ts-node", "src/logs-receiver", "./configs/config.json"] diff --git a/ebotsocket/Dockerfile b/ebotsocket/Dockerfile new file mode 100644 index 0000000..b549c92 --- /dev/null +++ b/ebotsocket/Dockerfile @@ -0,0 +1,9 @@ +FROM creativeprojects/php-nodejs:7.4 + +WORKDIR /app + +COPY ./setup.sh . + +RUN chmod +x setup.sh + +CMD ["./setup.sh"] diff --git a/ebotsocket/setup.sh b/ebotsocket/setup.sh new file mode 100644 index 0000000..67a7edb --- /dev/null +++ b/ebotsocket/setup.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Check if the .installed file exists +if [ ! -f .installed ]; then + + git clone https://github.com/deStrO/eBot-CSGO.git temp + + cp -n -R temp/* eBot-CSGO && rm -rf temp + + cd eBot-CSGO + + npm install + + composer install + + cd .. + + touch .installed + + cd eBot-CSGO + + sleep 120 + + php bootstrap.php +else + echo "eBot Socket is already installed. Skipping setup." + cd eBot-CSGO + php bootstrap.php +fi diff --git a/ebotweb/Dockerfile b/ebotweb/Dockerfile new file mode 100644 index 0000000..732eaa8 --- /dev/null +++ b/ebotweb/Dockerfile @@ -0,0 +1,17 @@ +FROM php:5.6.20-fpm + +WORKDIR /app + +RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mysql + +RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list + +RUN apt-get update && apt-get install -y --force-yes git && apt-get clean + +RUN echo 'date.timezone = Europe/Paris' >> /usr/local/etc/php/conf.d/timezone.ini + +COPY setup.sh . + +RUN chmod +x setup.sh + +CMD ["./setup.sh"] diff --git a/ebotweb/setup.sh b/ebotweb/setup.sh new file mode 100644 index 0000000..5822fc2 --- /dev/null +++ b/ebotweb/setup.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Check if the .installed file exists +if [ ! -f .installed ]; then + + git config --global http.sslverify false + + git clone https://github.com/deStrO/eBot-CSGO-Web.git temp + + cp -n -R temp/* eBot-CSGO-Web && rm -rf temp + + cd eBot-CSGO-Web + + sleep 30 + + php symfony cc + + php symfony doctrine:build --all --no-confirmation + + php symfony guard:create-user --is-super-admin admin@ebot admin admin + + rm -rf web/installation + + cd .. + + touch .installed + + php-fpm +else + echo "eBot Web is already installed. Skipping setup." + php-fpm +fi diff --git a/etc/eBotLogReceiver/config.json b/etc/eBotLogReceiver/config.json new file mode 100644 index 0000000..2093578 --- /dev/null +++ b/etc/eBotLogReceiver/config.json @@ -0,0 +1,45 @@ +{ + "logger": { + "name": "Logs #1", + "level": "debug" + }, + "udp": { + "enabled": true, + "ip": "0.0.0.0", + "port": 12345 + }, + "http": { + "enabled": true, + "ip": "0.0.0.0", + "port": 12345 + }, + "queues": [ + { + "type": "redis", + "config": { + "mode": "channel", + "channelName" : "ebot-logs", + "connection": { + "url": "redis://redis:6379" + } + } + } + ], + "plugins": [ + { + "path": "src/logs-receiver/plugins/logger.ts", + "config": { + "path": "logs", + "split": true + } + }, + { + "path": "src/logs-receiver/plugins/mapper.ts", + "config": { + "mapping": { + "127.0.0.1:27015": "192.168.0.1:27015" + } + } + } + ] + } \ No newline at end of file diff --git a/etc/eBotSocket/config.ini b/etc/eBotSocket/config.ini new file mode 100644 index 0000000..a08e4ef --- /dev/null +++ b/etc/eBotSocket/config.ini @@ -0,0 +1,60 @@ +; eBot - A bot for match management for CS:GO +; @license http://creativecommons.org/licenses/by/3.0/ Creative Commons 3.0 +; @author Julien Pardons +; @version 3.0 +; @date 21/10/2012 + +[BDD] +MYSQL_IP = "mysqldb" +MYSQL_PORT = "3306" +MYSQL_USER = "ebotv3" +MYSQL_PASS = "7w£6GfV0z92" +MYSQL_BASE = "ebotv3" + +[Config] +BOT_IP = "0.0.0.0" ; leave it as is (Docker) +BOT_PORT = 12360 +SSL_ENABLED = false +SSL_CERTIFICATE_PATH = "ssl/cert.pem" +SSL_KEY_PATH = "ssl/key.pem" +EXTERNAL_LOG_IP = "" ; use this in case your server isn't binded with the external IP (behind a NAT) +MANAGE_PLAYER = 1 +DELAY_BUSY_SERVER = 120 +NB_MAX_MATCHS = 0 +PAUSE_METHOD = "nextRound" ; nextRound or instantConfirm or instantNoConfirm +NODE_STARTUP_METHOD = "node" ; binary file name or none in case you are starting it with forever or manually +LOG_ADDRESS_SERVER = "http://127.0.0.1:12345" ; change the address to your extenral one +WEBSOCKET_SECRET_KEY = "helloworld" + +[Redis] +REDIS_HOST = "redis" +REDIS_PORT = 6379 +REDIS_AUTH_USERNAME = +REDIS_AUTH_PASSWORD = +REDIS_CHANNEL_LOG = "ebot-logs" +REDIS_CHANNEL_EBOT_FROM_WS = "ebot-from-ws" +REDIS_CHANNEL_EBOT_TO_WS = "ebot-to-ws" + +[Match] +LO3_METHOD = "restart" ; restart or csay or esl +KO3_METHOD = "restart" ; restart or csay or esl +DEMO_DOWNLOAD = true ; true or false :: whether gotv demos will be downloaded from the gameserver after matchend or not +REMIND_RECORD = false ; true will print the 3x "Remember to record your own POV demos if needed!" messages, false will not +DAMAGE_REPORT = true ; true will print damage reports at end of round to players, false will not +USE_DELAY_END_RECORD = false ; use the tv_delay to record postpone the tv_stoprecord & upload + +[MAPS] +MAP[] = "de_dust2" +MAP[] = "de_inferno" +MAP[] = "de_overpass" +MAP[] = "de_nuke" +MAP[] = "de_vertigo" +MAP[] = "de_ancient" +MAP[] = "de_anubis" + +[WORKSHOP IDs] + +[Settings] +COMMAND_STOP_DISABLED = true +RECORD_METHOD = "matchstart" ; matchstart or knifestart +DELAY_READY = true \ No newline at end of file diff --git a/etc/eBotWeb/app_user.yml b/etc/eBotWeb/app_user.yml new file mode 100644 index 0000000..f624cb9 --- /dev/null +++ b/etc/eBotWeb/app_user.yml @@ -0,0 +1,36 @@ +# ---------------------------------------------------------------------- +# white space are VERY important, don't remove it or it will not work +# ---------------------------------------------------------------------- + + log_match: ../../ebot-csgo/logs/log_match + log_match_admin: ../../ebot-csgo/logs/log_match_admin + demo_path: ../../ebot-csgo/demos + + default_max_round: 15 + default_rules: rules + default_overtime_max_round: 3 + default_overtime_startmoney: 16000 + + # true or false, whether demos will be downloaded by the ebot server + # the demos can be downloaded at the matchpage, if it's true + + demo_download: true + + ebot_ip: 127.0.0.1 # Change to your external IP + ebot_port: 12360 + + # lan or net, it's to display the server IP or the GO TV IP + # net mode display only started match on home page + mode: net + + # set to 0 if you don't want a refresh + refresh_time: 30 + + # Toornament Configuration + toornament_id: + toornament_secret: + toornament_api_key: + toornament_plugin_key: test-123457890 + + # Same as eBot config + websocket_secret_key: helloworld diff --git a/etc/eBotWeb/databases.yml b/etc/eBotWeb/databases.yml new file mode 100644 index 0000000..2a01b5b --- /dev/null +++ b/etc/eBotWeb/databases.yml @@ -0,0 +1,10 @@ +# You can find more information about this file on the symfony website: +# http://www.symfony-project.org/reference/1_4/en/07-Databases + +all: + doctrine: + class: sfDoctrineDatabase + param: + dsn: mysql:host=mysqldb;dbname=ebotv3 + username: ebotv3 + password: 7w£6GfV0z92 diff --git a/etc/nginx/default.conf b/etc/nginx/default.conf new file mode 100644 index 0000000..b125c82 --- /dev/null +++ b/etc/nginx/default.conf @@ -0,0 +1,34 @@ +server { + listen 80 ; + + server_name localhost; + + root /app/eBot-CSGO-Web/web; + + location ~ .php($|/) { + set $script $uri; + set $path_info ""; + + if ($uri ~ "^(.+.php)(/.+)") { + + set $script $1; + set $path_info $2; + } + fastcgi_split_path_info ^(.+.php)(/.+)$; + include fastcgi_params; + fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; + fastcgi_param HTTPS off; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_NAME $fastcgi_script_name; + fastcgi_pass eBotWeb:9000; + fastcgi_read_timeout 120; + } + + location / { + index index.php; + try_files $uri /index.php?$args; + } + + error_log /var/log/nginx/project_error.log; + access_log /var/log/nginx/project_access.log; +} \ No newline at end of file