-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed mongoose but it only does *some* session negotiation
- Loading branch information
1 parent
fde4520
commit 579d0a9
Showing
24 changed files
with
445 additions
and
504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,18 @@ | ||
FROM mongooseim/mongooseim:6.1.0-5-gabdcd0b48 | ||
# syntax=docker.io/docker/dockerfile:1.7-labs | ||
FROM python:3.11 | ||
|
||
ENV JOIN_CLUSTER=false | ||
ENV DUO_USE_VENV=false | ||
ENV PYTHONUNBUFFERED=true | ||
|
||
WORKDIR /app | ||
|
||
# MongooseIM config | ||
COPY service/chat/container/init-db.sh /init-db.sh | ||
COPY service/chat/container/init.sql /init.sql | ||
COPY service/chat/container/mongooseim.toml /usr/lib/mongooseim/etc/mongooseim.toml | ||
|
||
# Proxy | ||
COPY antiabuse/__init__.py /app/antiabuse/__init__.py | ||
COPY antiabuse/antirude /app/antiabuse/antirude | ||
COPY antiabuse/antispam /app/antiabuse/antispam | ||
COPY antiabuse/normalize /app/antiabuse/normalize | ||
COPY database /app/database | ||
COPY duohash /app/duohash | ||
COPY batcher /app/batcher | ||
COPY notify /app/notify | ||
COPY async_lru_cache /app/async_lru_cache | ||
COPY sql /app/sql | ||
COPY service/chat /app/service/chat | ||
COPY chat.main.sh /app | ||
COPY chat.auth.main.sh /app | ||
COPY chat.requirements.txt /app | ||
COPY \ | ||
--exclude=antiabuse/antiporn \ | ||
--exclude=test \ | ||
--exclude=vm \ | ||
. /app | ||
|
||
RUN : \ | ||
&& apt update \ | ||
&& apt install -y lsb-release wget \ | ||
&& sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \ | ||
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ | ||
&& apt update \ | ||
&& apt install -y postgresql-client python3-pip libpq5 \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& pip install --no-cache-dir -r /app/chat.requirements.txt | ||
|
||
CMD : \ | ||
&& /init-db.sh \ | ||
&& ( /app/chat.main.sh & ) \ | ||
&& /start.sh | ||
CMD /app/chat.main.sh |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
confusable-homoglyphs | ||
erlastic | ||
fastapi | ||
lxml | ||
nltk | ||
psycopg[binary] | ||
redis | ||
regex | ||
uvicorn | ||
websockets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
def create_dbs(): | ||
# All this stuff just to run `CREATE DATABASE IF NOT EXISTS DB_NAME` | ||
import os | ||
import psycopg | ||
import time | ||
|
||
DB_HOST = os.environ['DUO_DB_HOST'] | ||
DB_PORT = os.environ['DUO_DB_PORT'] | ||
DB_USER = os.environ['DUO_DB_USER'] | ||
DB_PASS = os.environ['DUO_DB_PASS'] | ||
|
||
_conninfo = psycopg.conninfo.make_conninfo( | ||
host=DB_HOST, | ||
port=DB_PORT, | ||
user=DB_USER, | ||
password=DB_PASS, | ||
) | ||
|
||
def create_db(name): | ||
for _ in range(10): | ||
try: | ||
with psycopg.connect(_conninfo, autocommit=True) as conn: | ||
with conn.cursor() as cur: | ||
cur.execute(f"CREATE DATABASE {name}") | ||
print(f'Created database: {name}') | ||
break | ||
except ( | ||
psycopg.errors.DuplicateDatabase, | ||
psycopg.errors.UniqueViolation, | ||
): | ||
print(f'Database already exists: {name}') | ||
break | ||
except psycopg.errors.OperationalError: | ||
print( | ||
'Creating database(s) failed; waiting and trying again:', | ||
e | ||
) | ||
time.sleep(1) | ||
|
||
create_db('duo_chat') | ||
|
||
def init_db(): | ||
# Now DB_NAME exists, we do do the rest of the init. | ||
from service import ( | ||
chat, | ||
) | ||
|
||
init_funcs = [ | ||
chat.init_db, | ||
] | ||
|
||
print('Initializing chat DB...') | ||
for i, init_func in enumerate(init_funcs, start=1): | ||
print(f' * {i} of {len(init_funcs)}') | ||
init_func() | ||
print('Finished initializing chat DB') | ||
|
||
create_dbs() | ||
init_db() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.