diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a2a7921 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.10-buster + + +RUN mkdir -p /app +COPY requirements.txt /app/ +RUN python3 -m pip install --upgrade pip && python3 -m pip install -r /app/requirements.txt + +COPY app/ /app/ +WORKDIR /app/ +ENV containterized true + +CMD ["python3", "server.py"] diff --git a/bot/__init__.py b/app/bot/__init__.py similarity index 100% rename from bot/__init__.py rename to app/bot/__init__.py diff --git a/app/bot/api/__init__.py b/app/bot/api/__init__.py new file mode 100644 index 0000000..7734fab --- /dev/null +++ b/app/bot/api/__init__.py @@ -0,0 +1,12 @@ +from . import reddit +from . import weather +from . import reddit +from . import search +from . import metmuseum +import os +if os.getenv("dockerized", "") == "true": + import sys + sys.path.append("/keys") + import api_keys as keys +else: + from . import keys \ No newline at end of file diff --git a/bot/api/metmuseum.py b/app/bot/api/metmuseum.py similarity index 100% rename from bot/api/metmuseum.py rename to app/bot/api/metmuseum.py diff --git a/bot/api/reddit.py b/app/bot/api/reddit.py similarity index 100% rename from bot/api/reddit.py rename to app/bot/api/reddit.py diff --git a/bot/api/search.py b/app/bot/api/search.py similarity index 100% rename from bot/api/search.py rename to app/bot/api/search.py diff --git a/bot/api/weather.py b/app/bot/api/weather.py similarity index 100% rename from bot/api/weather.py rename to app/bot/api/weather.py diff --git a/bot/commands/__init__.py b/app/bot/commands/__init__.py similarity index 100% rename from bot/commands/__init__.py rename to app/bot/commands/__init__.py diff --git a/bot/commands/alias.py b/app/bot/commands/alias.py similarity index 100% rename from bot/commands/alias.py rename to app/bot/commands/alias.py diff --git a/bot/commands/clock.py b/app/bot/commands/clock.py similarity index 100% rename from bot/commands/clock.py rename to app/bot/commands/clock.py diff --git a/bot/commands/help.py b/app/bot/commands/help.py similarity index 100% rename from bot/commands/help.py rename to app/bot/commands/help.py diff --git a/bot/commands/lists.py b/app/bot/commands/lists.py similarity index 100% rename from bot/commands/lists.py rename to app/bot/commands/lists.py diff --git a/bot/commands/plaintext.py b/app/bot/commands/plaintext.py similarity index 100% rename from bot/commands/plaintext.py rename to app/bot/commands/plaintext.py diff --git a/bot/commands/reddit.py b/app/bot/commands/reddit.py similarity index 100% rename from bot/commands/reddit.py rename to app/bot/commands/reddit.py diff --git a/bot/commands/search.py b/app/bot/commands/search.py similarity index 100% rename from bot/commands/search.py rename to app/bot/commands/search.py diff --git a/bot/commands/status.py b/app/bot/commands/status.py similarity index 100% rename from bot/commands/status.py rename to app/bot/commands/status.py diff --git a/bot/commands/template.py b/app/bot/commands/template.py similarity index 100% rename from bot/commands/template.py rename to app/bot/commands/template.py diff --git a/bot/commands/weather.py b/app/bot/commands/weather.py similarity index 100% rename from bot/commands/weather.py rename to app/bot/commands/weather.py diff --git a/bot/commands/zvv.py b/app/bot/commands/zvv.py similarity index 100% rename from bot/commands/zvv.py rename to app/bot/commands/zvv.py diff --git a/bot/main.py b/app/bot/main.py similarity index 96% rename from bot/main.py rename to app/bot/main.py index 82fbf79..6591462 100644 --- a/bot/main.py +++ b/app/bot/main.py @@ -66,4 +66,4 @@ class ChatBot(): self.telegram.start_polling( poll_interval=0.2, ) - # self.telegram.idle() + self.telegram.idle() diff --git a/broadcast/__init__.py b/app/broadcast/__init__.py similarity index 100% rename from broadcast/__init__.py rename to app/broadcast/__init__.py diff --git a/broadcast/b_in.py b/app/broadcast/b_in.py similarity index 100% rename from broadcast/b_in.py rename to app/broadcast/b_in.py diff --git a/broadcast/b_out.py b/app/broadcast/b_out.py similarity index 100% rename from broadcast/b_out.py rename to app/broadcast/b_out.py diff --git a/client.py b/app/client.py similarity index 100% rename from client.py rename to app/client.py diff --git a/clock/__init__.py b/app/clock/__init__.py similarity index 100% rename from clock/__init__.py rename to app/clock/__init__.py diff --git a/clock/c_back.py b/app/clock/c_back.py similarity index 100% rename from clock/c_back.py rename to app/clock/c_back.py diff --git a/clock/c_in.py b/app/clock/c_in.py similarity index 100% rename from clock/c_in.py rename to app/clock/c_in.py diff --git a/clock/c_out.py b/app/clock/c_out.py similarity index 100% rename from clock/c_out.py rename to app/clock/c_out.py diff --git a/clock/hardware/__init__.py b/app/clock/hardware/__init__.py similarity index 100% rename from clock/hardware/__init__.py rename to app/clock/hardware/__init__.py diff --git a/clock/hardware/led.py b/app/clock/hardware/led.py similarity index 100% rename from clock/hardware/led.py rename to app/clock/hardware/led.py diff --git a/clock/hardware/neopixel.py b/app/clock/hardware/neopixel.py similarity index 100% rename from clock/hardware/neopixel.py rename to app/clock/hardware/neopixel.py diff --git a/clock/hardware/sensors.py b/app/clock/hardware/sensors.py similarity index 100% rename from clock/hardware/sensors.py rename to app/clock/hardware/sensors.py diff --git a/clock/hardware/sim.py b/app/clock/hardware/sim.py similarity index 100% rename from clock/hardware/sim.py rename to app/clock/hardware/sim.py diff --git a/clock/hardware/unicorn.py b/app/clock/hardware/unicorn.py similarity index 100% rename from clock/hardware/unicorn.py rename to app/clock/hardware/unicorn.py diff --git a/clock/helpers/__init__.py b/app/clock/helpers/__init__.py similarity index 100% rename from clock/helpers/__init__.py rename to app/clock/helpers/__init__.py diff --git a/clock/helpers/computations.py b/app/clock/helpers/computations.py similarity index 100% rename from clock/helpers/computations.py rename to app/clock/helpers/computations.py diff --git a/clock/helpers/shapes.py b/app/clock/helpers/shapes.py similarity index 100% rename from clock/helpers/shapes.py rename to app/clock/helpers/shapes.py diff --git a/clock/helpers/timer.py b/app/clock/helpers/timer.py similarity index 100% rename from clock/helpers/timer.py rename to app/clock/helpers/timer.py diff --git a/clock/helpers/weather-icons.bmp b/app/clock/helpers/weather-icons.bmp similarity index 100% rename from clock/helpers/weather-icons.bmp rename to app/clock/helpers/weather-icons.bmp diff --git a/launcher.py b/app/launcher.py similarity index 100% rename from launcher.py rename to app/launcher.py diff --git a/persistence/README.md b/app/persistence/README.md similarity index 100% rename from persistence/README.md rename to app/persistence/README.md diff --git a/persistence/__init__.py b/app/persistence/__init__.py similarity index 100% rename from persistence/__init__.py rename to app/persistence/__init__.py diff --git a/persistence/database.py b/app/persistence/database.py similarity index 90% rename from persistence/database.py rename to app/persistence/database.py index ad80a00..31246e3 100644 --- a/persistence/database.py +++ b/app/persistence/database.py @@ -7,8 +7,14 @@ import logging logger = logging.getLogger(__name__) -from . import keys -dbk = keys.db_keys +import os +if os.getenv("dockerized", "") == "true": + import sys + sys.path.append("/keys") + import db_keys as keys +else: + from . import keys +dbk = keys.db_access diff --git a/persistence/local_io.py b/app/persistence/local_io.py similarity index 100% rename from persistence/local_io.py rename to app/persistence/local_io.py diff --git a/persistence/models.py b/app/persistence/models.py similarity index 100% rename from persistence/models.py rename to app/persistence/models.py diff --git a/server.py b/app/server.py similarity index 91% rename from server.py rename to app/server.py index 8ca3ba5..08a5d50 100644 --- a/server.py +++ b/app/server.py @@ -8,8 +8,8 @@ import logging import platform -if platform.uname().node == "ArchSpectre": - # development +import os +if os.getenv("dockerized", "") == "true" or platform.uname().node == "ArchSpectre": logging.basicConfig( format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO ) diff --git a/bot/api/__init__.py b/bot/api/__init__.py deleted file mode 100644 index 97cff3a..0000000 --- a/bot/api/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from . import keys -from . import reddit -from . import weather -from . import reddit -from . import search -from . import metmuseum \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 8360100..58f60c1 100644 Binary files a/requirements.txt and b/requirements.txt differ