Backend server for cs2 battle discord bot
- Setting Up Docker Create a Docker network for the CS2 Battle Bot:
docker network create cs2-battle-bot-network
- Docker Compose Configuration Create a docker-compose.yml file with the following configuration:
services:
app:
container_name: cs2_battle_bot_api
image: qwizii/cs2-battle-bot-api:latest
command: gunicorn cs2_battle_bot.wsgi:application --bind 0.0.0.0:8000
ports:
- "8003:8000"
environment:
- SECRET_KEY=django-insecure-#
- DB_ENGINE=django.db.backends.postgresql
- DB_HOST=db
- DB_NAME=cs2_db
- DB_USER=cs2_user
- DB_PASSWORD=cs2_password
- DB_PORT=5432
- REDIS_URL=redis://redis:6379/0
- HOST_URL=http://localhost:8003
- DISCORD_CLIENT_ID=
- DISCORD_CLIENT_SECRET=
- DISCORD_REDIRECT_URI=http://localhost:8003/accounts/discord/callback
- STEAM_API_KEY=
- STEAM_REDIRECT_URI=https://localhost:8003/accounts/steam/callback
- RCON_HOST=
- RCON_PORT=
- RCON_PASSWORD=
- API_KEY=
restart: always
depends_on:
- db
networks:
- cs2-battle-bot-network
db:
image: postgres:15.1
container_name: cs2_battle_bot_db
environment:
- POSTGRES_DB=cs2_db
- POSTGRES_USER=cs2_user
- POSTGRES_PASSWORD=cs2_password
restart: always
expose:
- "5435:5432"
networks:
- cs2-battle-bot-network
redis:
image: "redis:alpine"
container_name: cs2_battle_bot_redis
restart: always
expose:
- "6379:6379"
networks:
- cs2-battle-bot-network
networks:
cs2-battle-bot-network:
external: true
- Building and Running Containers Build and run the containers:
docker compose up -d --build
- Running Migrations Run migrations:
docker compose exec app python manage.py migrate
- Creating Super User Create a superuser:
docker compose exec app python manage.py createsuperuser
- Creating API Key
- Access the admin panel at http://localhost:8003/admin/ using the superuser credentials.
- Navigate to the API Keys section.
- Click on the "Add" button to create a new API key, providing a name and expiration date.
- Save the API key.
- After completing the previous steps, you will see a message similar to the following in the admin panel:
- Update the API_KEY environment variable in your docker-compose.yml file with the new key.
- Rebuild the containers:
docker compose up -d --build
- Add maps: Run fixture with maps
docker compose exec app python manage.py loaddata maps