docker bush ended

This commit is contained in:
bacon
2024-03-22 01:07:29 +03:00
parent 62a8921e10
commit 37eef98e20
5 changed files with 24 additions and 16 deletions

11
.dockerignore Normal file
View File

@@ -0,0 +1,11 @@
/tmp/
audio/*/
/.idea
user.db
*.pyc
/.run/
.env
*.exe
/venv/
config.json
.editorconfig

View File

@@ -74,7 +74,7 @@ services:
- name: docker:25.0.5-dind - name: docker:25.0.5-dind
entrypoint: [ "env", "-u", "DOCKER_HOST" ] entrypoint: [ "env", "-u", "DOCKER_HOST" ]
Build: make_image:
stage: build stage: build
image: docker:25.0.5-dind image: docker:25.0.5-dind
services: services:

View File

@@ -1,24 +1,22 @@
FROM intel/intel-optimized-ffmpeg:avx2 as builder FROM python:3.12.2-slim-bookworm as builder
LABEL authors="bacon" LABEL authors="bacon"
WORKDIR /app WORKDIR /app
COPY requirements.txt /app COPY requirements.txt /app
RUN apt-get update -qq && \ RUN pip wheel install \
apt-get install -qq --no-install-recommends python3-pip -y && \
apt-get clean -qq autoclean && \
pip wheel install \
--no-cache-dir -q \ --no-cache-dir -q \
--no-deps --wheel-dir /app/wheels \ --no-deps --wheel-dir /app/wheels \
-r requirements.txt -r requirements.txt
FROM intel/intel-optimized-ffmpeg:avx2 as runner FROM python:3.12.2-slim-bookworm as runner
WORKDIR /app WORKDIR /app
COPY --from=builder /app/wheels /wheels COPY --from=builder /app/wheels /wheels
RUN apt-get update -qq && \ RUN apt-get update -qq && \
apt-get install -qq --no-install-recommends libopus-dev python3-pip -y && \ apt-get install -qq --no-install-recommends ffmpeg -y && \
apt-get clean -qq autoclean && \ apt-get clean -qq autoclean && \
pip install --no-cache -q /wheels/* pip install --no-cache -q /wheels/*
COPY src/ /app COPY src/ /app
ENTRYPOINT ["python3", "bot.py"] ENTRYPOINT ["python", "bot.py"]
#ENTRYPOINT ["ffmpeg"]

View File

@@ -1,6 +1,6 @@
version: "1.0" version: "1.0"
bootstrap: | bootstrap: |
rm -rf .idea rm -rf .idea
pip install --quiet -U -r requirements.txt pip install --quiet -r requirements.txt
profile: profile:
name: qodana.recommended name: qodana.recommended

View File

@@ -18,8 +18,7 @@ class DBReader:
try: try:
sql_con = connect("user.db") sql_con = connect("user.db")
cursor = sql_con.cursor() cursor = sql_con.cursor()
cursor.execute("""SELECT * FROM "(guildid)" """, cursor.execute(f"""SELECT * FROM "{guildid}" """)
{'guildid': guildid})
record = cursor.fetchall() record = cursor.fetchall()
return record return record
except Error as _e: except Error as _e:
@@ -86,9 +85,9 @@ async def prepare_db(guild: int):
try: try:
_connect = connect('user.db') _connect = connect('user.db')
cursor = _connect.cursor() cursor = _connect.cursor()
cursor.execute(f'''CREATE TABLE IF NOT EXISTS "{guild}" cursor.execute(f'CREATE TABLE IF NOT EXISTS "{guild}"\n'
([userid] INTEGER PRIMARY KEY, [username] TEXT, f' ([userid] INTEGER PRIMARY KEY, [username] TEXT,\n'
[nick] TEXT, [isbot] BOOL, [defaulttracks] TEXT, [usertracks] TEXT)''') f' [nick] TEXT, [isbot] BOOL, [defaulttracks] TEXT, [usertracks] TEXT)')
cursor.close() cursor.close()
except Error as _error: except Error as _error:
logger.info(_error) logger.info(_error)
@@ -111,7 +110,7 @@ async def work_with_db(db_func: str, data_turple: tuple):
async def fill_bd(name: str, userid: int, isbot: bool, nick: str, guild: int): async def fill_bd(name: str, userid: int, isbot: bool, nick: str, guild: int):
sqlite_insert_with_param = (f"""INSERT OR IGNORE INTO "{guild}" sqlite_insert_with_param = (f"""INSERT OR IGNORE INTO '{guild}'
(username, userid, nick, isbot) (username, userid, nick, isbot)
VALUES (?, ?, ?, ?)""") VALUES (?, ?, ?, ?)""")
data_tuple: tuple[str, int, str, bool] = (name, userid, nick, isbot) data_tuple: tuple[str, int, str, bool] = (name, userid, nick, isbot)