Continue fixing stuff; Add okteto support (manual build as far)

pull/1/head
hikari.ftg 2022-03-22 15:03:50 +00:00
parent beccf6098d
commit e0d59eeb3e
9 changed files with 30 additions and 45 deletions

View File

@ -1,11 +1,6 @@
ENV TZ=Europe/Moscow
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& git clone https://github.com/hikariatama/Hikka.git /root/Hikka/ \
&& pip3 install --no-cache-dir -r root/Hikka/requirements.txt \
&& pip3 install av --no-binary av
WORKDIR /root/Hikka/
# start the bot
CMD ["python3", "-m", "hikka", "--root"]
FROM python:3.8
ADD . /
ENV OKTETO=true
RUN pip install -r requirements.txt
EXPOSE 8080
CMD ["python3", "-m", "hikka"]

View File

@ -1,3 +0,0 @@
worker-DO-NOT-TURN-ON-OR-THINGS-WILL-BREAK: python3 -m friendly-telegram
web: python3 -m friendly-telegram --heroku-web-internal
restarter-DO-NOT-TURN-ON-OR-THINGS-WILL-BREAK: python3 -m friendly-telegram --heroku-restart-internal

View File

@ -1,8 +0,0 @@
version: "3.9"
services:
worker:
build: .
environment:
SESSION: $SESSION
API_ID: $API_ID
API_HASH: $API_HASH

View File

@ -22,7 +22,11 @@ import sys
import getpass
import os
if getpass.getuser() == "root" and "--root" not in " ".join(sys.argv):
if (
getpass.getuser() == "root"
and "--root" not in " ".join(sys.argv)
and "OKTETO" not in os.environ
):
print("!" * 30)
print("NEVER EVER RUN USERBOT FROM ROOT")
print("THIS IS THE THREAD FOR NOT ONLY YOUR DATA, ")
@ -53,7 +57,9 @@ else:
"Attempting dependencies installation... Just wait."
)
os.popen("pip3 install -r requirements.txt").read() # skipcq: BAN-B605, BAN-B607
os.popen(
"pip3 install -r requirements.txt"
).read() # skipcq: BAN-B605, BAN-B607
try:
from . import main

View File

@ -100,7 +100,9 @@ save_config_key("use_fs_for_modules", get_config_key("use_fs_for_modules"))
def gen_port():
# TODO: Oktato 8080 default
if "OKTETO" in os.environ:
return 8080
# But for own server we generate new free port, and assign to it
port = get_config_key("port")

View File

@ -240,7 +240,7 @@ class LoaderMod(loader.Module):
preset = "minimal"
r = await utils.run_sync(
requests.get, self.config["MODULES_REPO"] + "/" + preset + ".txt"
requests.get, self.config["MODULES_REPO"].strip("/") + "/" + preset + ".txt"
)
r.raise_for_status()
return set(filter(lambda x: x, r.text.split("\n")))
@ -250,7 +250,7 @@ class LoaderMod(loader.Module):
if urllib.parse.urlparse(module_name).netloc:
url = module_name
else:
url = self.config["MODULES_REPO"] + module_name + ".py"
url = self.config["MODULES_REPO"].strip("/") + "/" + module_name + ".py"
r = await utils.run_sync(requests.get, url)

11
okteto-stack.yaml 100644
View File

@ -0,0 +1,11 @@
name: hikka
services:
worker:
public: true
build: .
replicas: 1
ports:
- 8080
resources:
cpu: 900m
memory: 2Gi

View File

@ -1,12 +0,0 @@
name: hikka
image: python:3
command: ["python3", "-m", "hikka", "--root"]
sync:
- .:/usr/src/app
forward:
- 8080:8080
reverse:
- 9000:9000
autocreate: true
volumes:
- /root/.cache/pip

6
run
View File

@ -1,6 +0,0 @@
echo "
█ █ █ █▄▀ █▄▀ ▄▀█
█▀█ █ █ █ █ █ █▀█
Is starting...
"
python3 -m hikka --root