diff --git a/.gitignore b/.gitignore index 14812f4..5e0c395 100644 --- a/.gitignore +++ b/.gitignore @@ -162,3 +162,4 @@ app/run_venv.sh # Local History for Visual Studio Code .history/ +/reference config/ diff --git a/app/Dockerfile b/app/Dockerfile index dc42477..70c0393 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,7 +1,10 @@ FROM python:slim -COPY . /usr/src/app -WORKDIR /usr/src/app -RUN apt-get update -y && apt-get upgrade -y && apt-get install libopus0 -y && \ - pip install --upgrade pip && pip install -r requirements.txt && \ - apt-get autoremove -y +COPY . /app +WORKDIR /app +RUN apt-get update -y +RUN apt-get upgrade -y +RUN apt-get install libopus0 -y +RUN pip install --upgrade pip +RUN pip install -r requirements.txt +RUN apt-get autoremove -y CMD python3 -u ./bot.py \ No newline at end of file diff --git a/app/bot.py b/app/bot.py index f5fa4ee..4be5fb2 100644 --- a/app/bot.py +++ b/app/bot.py @@ -25,9 +25,13 @@ def yaml_dump(data:dict, filepath:str): yaml.dump(data, file) # Locate or create config file. Read from environment variables to locate file, and if missing or not valid then use default location. -configFile = os.getenv('CONFIG') if ((os.getenv('CONFIG').endswith('.yml') or os.getenv('CONFIG').endswith('.yaml')) and not os.getenv('CONFIG').endswith('config_blueprint.yml')) else './data/config.yml' +configFile = './data/config.yml' +if os.getenv('CONFIG'): + if os.getenv('CONFIG').endswith(('.yml','.yaml')) and not os.getenv('CONFIG').endswith('config_blueprint.yml'): + configFile = os.getenv('CONFIG') -if not os.path.exists(configFile): yaml_dump({},configFile) +if not os.path.exists(configFile): + yaml_dump({},configFile) # Locate or create data file. Same as above. dataFile = os.getenv('DATA') if ((os.getenv('DATA').endswith('.yml') or os.getenv('DATA').endswith('.yaml')) and not os.getenv('DATA').endswith('data_blueprint.yml')) else './data/data.yml' diff --git a/docker-compose-nas.yml b/docker-compose-nas.yml new file mode 100644 index 0000000..6a41a4c --- /dev/null +++ b/docker-compose-nas.yml @@ -0,0 +1,9 @@ +version: '3.5' + +services: + geasbot-app: + build: ./app + container_name: geas_bot + volumes: + - /share/Public/geasbot/data:/app/data + restart: unless-stopped \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 28c6c8d..03d745e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,5 +5,5 @@ services: build: ./app container_name: geas_bot volumes: - - ./app:/usr/src/app + - ./app:/app restart: unless-stopped \ No newline at end of file