The bot for the Networking Discord server
This bot is prepared to run either as a bare Python script, Heroku dyno, or Docker image. In this guide, the running configurations will be knows as 'direct', 'heroku' or docker respectively. All configuration options are therefore intended to be set via environment variables.
echo "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())" | python3 1 ↵
If you're using Kubernetes, Docker, or Heroku, create file in the base of the project named .env
with the contents:
Replace all values as appropriate:
BOT_DESCRIPTION='[testing] The Networking Discord Bot'
COMMAND_PREFIX=^
EGGSROLE_NAME='!eggs'
GUILD_NAME=Networking-Dev
LOGCHANNEL_NAME=cnc
MEMBERCHANNEL_NAME=general
MEMBERROLE_NAME=Members
TOKEN=<YourBotsPrivateToken>
WELCOMECHANNEL_NAME=welcome
MIRRORCHANNEL_NAME=egg-qc
SMTP_USERNAME=mysmtpusername
SMTP_PASSWORD=mysmtppassword
SMTP_SERVER=in-v3.mailjet.com
SMTP_PORT=587
[email protected]
SECRETKEY=Secret key from Step 1
DB_HOST=mongodb.hostname
DB_PORT=27017
DB_NAME=network_ranger
DB_USER=<dbuser>
#DB_PASS=<dbpass>
If you're running this directly instead of as a container, you will need to load each one of these as an environment variable. Also, DB_PASS is commented as it should be loaded from your MongoDB secret if installed with Kubernetes. If not running with Kubernetes, you'll need to populate this.
- 3.A.0. Prerequisites:
- MongoDB installed and running in the namespace you'll use for network-ranger. We recommend use of the helm chart to
achieve this:
helm repo add bitmami https://hub.helm.sh/charts/bitnami helm install -n network-ranger mongodb bitnami/mongodb
- MongoDB installed and running in the namespace you'll use for network-ranger. We recommend use of the helm chart to
achieve this:
- 3.A.1. Copy the example:
cp kube-deploy.example.yaml kube-deploy.yaml
- 3.A.2. Modify
kube-deploy.yaml
to your liking. The default should work for most users. - 3.A.3. Create the deployment:
kubectl create -f kube-deploy.yaml
- 3.A.4. Create your secret from your .env file
kubectl create secret generic network-ranger -n network-ranger --from-env-file .env
- 3.A.5. Check that the pod is running
kubectl get pods -n network-ranger
- 3.B.1.
cd
into your directory containing the.env
file you created in Step 2 - 3.B.2. Run the Docker container either by:
- Loading from DockerHub to pull a the remote image:
docker run --env-file=.env netdiscord/network-ranger:latest
- Building your own local copy, assuming that the Dockerfile is in your
pwd
and running:docker build -t network-ranger . docker run --env-file=.env network-ranger
- Loading from DockerHub to pull a the remote image:
- 3.C.A.1.
cd
into your directory containing the.env
file you created in Step 2. This must also be the base directory of the project in which theDockerfile
resides. - 3.C.A.2. Run the container with
heroku local
- This is outside the scope of this guide but general instructions can be found on Heroku's website.
- You will need to load the environment
variables into your Dyno as they will not be taken directly from your
.env
file by default. - This method is no longer actively tested.
- Install the requirements in
requirements.txt
:pip install -r requirements.txt
- Run the script:
python3 network_ranger