Implemented Env-Change

This commit is contained in:
jmueller
2023-12-14 18:16:22 +01:00
parent 0ea4fd74f3
commit f118861c05
2 changed files with 14 additions and 3 deletions

6
Dockerfile Normal file
View File

@@ -0,0 +1,6 @@
FROM python:3.10
LABEL authors="jmueller"
ADD main.py .
RUN pip install py-cord mariadb python-dotenv
CMD ["python", "./main.py"]

View File

@@ -6,10 +6,15 @@ import mariadb
import sys import sys
from discord import default_permissions from discord import default_permissions
load_dotenv() # load all the variables from the env file configfile = "config.json"
if os.path.exists(configfile):
with open('config.json') as user_file: with open('config.json') as user_file:
config = json.loads(user_file.read()) config = json.loads(user_file.read())
else:
config = {"db_user": os.environ["db_user"], "db_password": os.environ["db_password"], "db_host": os.environ["db_host"], "db_pass": os.environ["db_pass"]}
if os.path.exists(".env"):
load_dotenv()
def connect_db(): def connect_db():