Implemented Env-Change
This commit is contained in:
6
Dockerfile
Normal file
6
Dockerfile
Normal 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"]
|
||||||
11
main.py
11
main.py
@@ -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():
|
||||||
|
|||||||
Reference in New Issue
Block a user