diff --git a/Dockerfile b/Dockerfile index 3f7084b..be856a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,4 @@ RUN pip3 install -r requirements.txt COPY . . -CMD [ "python3", "main.py"] #Uncomment to start with the Docker Container \ No newline at end of file +CMD [ "python3", "main.py"] \ No newline at end of file diff --git a/Dockerfile_standalone_DiscordScript b/Dockerfile_standalone_DiscordScript new file mode 100644 index 0000000..c25b1f0 --- /dev/null +++ b/Dockerfile_standalone_DiscordScript @@ -0,0 +1,10 @@ +FROM python:3.8-buster + +WORKDIR /Praxis + +COPY requirements.txt requirements.txt +RUN pip3 install -r requirements.txt + +COPY . . + +CMD [ "python3", "discord_script_standalone.py"] \ No newline at end of file diff --git a/Dockerfile_standalone_TwitchScript b/Dockerfile_standalone_TwitchScript new file mode 100644 index 0000000..02056ff --- /dev/null +++ b/Dockerfile_standalone_TwitchScript @@ -0,0 +1,10 @@ +FROM python:3.8-buster + +WORKDIR /Praxis + +COPY requirements.txt requirements.txt +RUN pip3 install -r requirements.txt + +COPY . . + +CMD [ "python3", "twitch_script_standalone.py"] \ No newline at end of file diff --git a/Dockerfile_standalone_command b/Dockerfile_standalone_command new file mode 100644 index 0000000..c0e9965 --- /dev/null +++ b/Dockerfile_standalone_command @@ -0,0 +1,10 @@ +FROM python:3.8-buster + +WORKDIR /Praxis + +COPY requirements.txt requirements.txt +RUN pip3 install -r requirements.txt + +COPY . . + +CMD [ "python3", "standalone_command.py"] \ No newline at end of file diff --git a/README.md b/README.md index b7de009..a7204e2 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,28 @@ ___ ## Usage: -Run the following to enable these V2 modules. +Run the following to enable these V2 modules without Docker. (After you install requirements)
+`pip install -r requirements.txt`
`python standalone_command.py`
-`python twitch_script_standalone`
-`python discord_script_standalone`
+`python twitch_script_standalone.py`
+`python discord_script_standalone.py`
+## Docker: + +### Image Setup: + +Use these commands to build the images.
+`docker build --file Dockerfile_standalone_command --tag standalone_command .`
+`docker build --file Dockerfile_standalone_TwitchScript --tag twitchscript_standalone .`
+`docker build --file Dockerfile_standalone_DiscordScript --tag discordscript_standalone .`
+ +### Docker-Compose Info: + +To Start: +`docker-compose up`
+To Stop: +`docker-compose down`
___ ~~# V1 Info:~~ diff --git a/discord_script_standalone.py b/discord_script_standalone.py index c47d723..c71a971 100644 --- a/discord_script_standalone.py +++ b/discord_script_standalone.py @@ -85,14 +85,14 @@ class Discord_Module(discord.Client): async def is_command(self, word: str) -> bool: # todo need to url-escape word clean_param = urlencode({'name': word}) - url = "http://localhost:5000/api/v1/command?%s" % clean_param + url = "http://standalone_command:5000/api/v1/command?%s" % clean_param resp = requests.get(url) return resp.status_code == 200 async def exec_command(self, realMessage: discord.Message, command: str, rest: str): # todo need to url-escape command and rest params = urlencode({'command_source': commands.command_base.AbstractCommand.CommandSource.Discord, 'user_name': realMessage.author.mention, 'command_name': command, 'rest': rest, 'bonus_data': realMessage}) - url = "http://localhost:5000/api/v1/exec?%s" % params + url = "http://standalone_command:5000/api/v1/exec?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..02d31c4 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,16 @@ +version: '3.7' +services: + standalone_command: + image: standalone_command + ports: + - 5000:5000 + environment: + - ISDOCKER=cat + twitchscript_standalone: + image: twitchscript_standalone + environment: + - ISDOCKER=cat + discordscript_standalone: + image: discordscript_standalone + environment: + - ISDOCKER=cat \ No newline at end of file diff --git a/twitch_script_standalone.py b/twitch_script_standalone.py index 867074a..03eac64 100644 --- a/twitch_script_standalone.py +++ b/twitch_script_standalone.py @@ -69,14 +69,14 @@ class Twitch_Module(): def is_command(self, word: str) -> bool: # todo need to url-escape word clean_param = urlencode({'name': word}) - url = "http://localhost:5000/api/v1/command?%s" % clean_param + url = "http://standalone_command:5000/api/v1/command?%s" % clean_param resp = requests.get(url) return resp.status_code == 200 def exec_command(self, realMessage: twitch.chat.Message, command: str, rest: str): # todo need to url-escape command and rest params = urlencode({'command_source': commands.command_base.AbstractCommand.CommandSource.Twitch,'user_name': realMessage.sender, 'command_name': command, 'rest': rest, 'bonus_data': realMessage}) - url = "http://localhost:5000/api/v1/exec?%s" % params + url = "http://standalone_command:5000/api/v1/exec?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text)