diff options
author | clarkzjw <[email protected]> | 2023-02-23 22:24:05 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-23 22:24:05 -0800 |
commit | af610ab49194f12783fdfb2cc676c4877b22ed7c (patch) | |
tree | be43b7324d06886ad1ed41a015bd356ae9320d56 | |
parent | a9fb6f252553ae49a2ba372434073824babe31e4 (diff) | |
download | swarm2fediverse-af610ab49194f12783fdfb2cc676c4877b22ed7c.tar.gz |
deploy: add Dockerfile and docker-compose.yaml
-rw-r--r-- | .dockerignore | 3 | ||||
-rw-r--r-- | Dockerfile | 11 | ||||
-rw-r--r-- | bot.py | 2 | ||||
-rw-r--r-- | config.ini.example | 7 | ||||
-rw-r--r-- | config.py | 11 | ||||
-rw-r--r-- | contrib/docker-compose.yaml | 13 | ||||
-rw-r--r-- | dbstore/peewee_store.py | 2 | ||||
-rw-r--r-- | requirements.txt | 8 |
8 files changed, 41 insertions, 16 deletions
diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8a229dd --- /dev/null +++ b/.dockerignore | |||
@@ -0,0 +1,3 @@ | |||
1 | .venv/ | ||
2 | *.db | ||
3 | *.ini | ||
@@ -1 +1,10 @@ | |||
1 | FROM python:3 | 1 | FROM python:3.10 |
2 | |||
3 | WORKDIR /usr/src/app | ||
4 | |||
5 | COPY requirements.txt ./ | ||
6 | RUN pip install --no-cache-dir -r requirements.txt | ||
7 | |||
8 | COPY . . | ||
9 | |||
10 | CMD [ "python", "./bot.py" ] | ||
@@ -229,7 +229,7 @@ async def main() -> None: | |||
229 | app=starlette_app, | 229 | app=starlette_app, |
230 | port=BOT_PORT, | 230 | port=BOT_PORT, |
231 | use_colors=False, | 231 | use_colors=False, |
232 | host="100.93.242.2", | 232 | host="0.0.0.0", |
233 | ) | 233 | ) |
234 | ) | 234 | ) |
235 | 235 | ||
diff --git a/config.ini.example b/config.ini.example index e3a9121..d52a4d1 100644 --- a/config.ini.example +++ b/config.ini.example | |||
@@ -2,3 +2,10 @@ | |||
2 | BOT_TOKEN = | 2 | BOT_TOKEN = |
3 | FOURSQUARE_API_KEY = | 3 | FOURSQUARE_API_KEY = |
4 | ENCRYPT_KEY = | 4 | ENCRYPT_KEY = |
5 | |||
6 | [API] | ||
7 | TELEGRAM_WEBHOOK_URL = "/checkinbot/webhook" | ||
8 | HEALTHCHECK_URL = "/checkinbot/healthcheck" | ||
9 | FEDI_LOGIN_CALLBACK_URL = "/checkinbot/fedi_login_callback" | ||
10 | BOT_DOMAIN = "https://" | ||
11 | BOT_PORT = 8080 | ||
@@ -10,6 +10,12 @@ BOT_TOKEN = config["DEFAULT"]["BOT_TOKEN"] | |||
10 | FSQ_API_KEY = config["DEFAULT"]["FOURSQUARE_API_KEY"] | 10 | FSQ_API_KEY = config["DEFAULT"]["FOURSQUARE_API_KEY"] |
11 | ENCRYPT_KEY = config["DEFAULT"]["ENCRYPT_KEY"] | 11 | ENCRYPT_KEY = config["DEFAULT"]["ENCRYPT_KEY"] |
12 | 12 | ||
13 | TELEGRAM_WEBHOOK_URL = config["API"]["TELEGRAM_WEBHOOK_URL"] | ||
14 | HEALTHCHECK_URL = config["API"]["HEALTHCHECK_URL"] | ||
15 | FEDI_LOGIN_CALLBACK_URL = config["API"]["FEDI_LOGIN_CALLBACK_URL"] | ||
16 | BOT_DOMAIN = config["API"]["BOT_DOMAIN"] | ||
17 | BOT_PORT = int(config["API"]["BOT_PORT"]) | ||
18 | |||
13 | MEDIA_GROUP_TIMEOUT = 3 | 19 | MEDIA_GROUP_TIMEOUT = 3 |
14 | 20 | ||
15 | FEDI_LOGIN, WAIT_VISIBILITY, WAIT_LOCATION, LOCATION_SEARCH_KEYWORD, LOCATION_CONFIRMATION, ADD_MEDIA, ADD_COMMENT = range(7) | 21 | FEDI_LOGIN, WAIT_VISIBILITY, WAIT_LOCATION, LOCATION_SEARCH_KEYWORD, LOCATION_CONFIRMATION, ADD_MEDIA, ADD_COMMENT = range(7) |
@@ -41,9 +47,4 @@ class MsgDict(TypedDict): | |||
41 | KEY_TOOT_STATUS_ID = "toot_status_id" | 47 | KEY_TOOT_STATUS_ID = "toot_status_id" |
42 | KEY_TOOT_STATUS_CONTENT = "toot_status_content" | 48 | KEY_TOOT_STATUS_CONTENT = "toot_status_content" |
43 | 49 | ||
44 | TELEGRAM_WEBHOOK_URL = "/checkinbot/webhook" | ||
45 | HEALTHCHECK_URL = "/checkinbot/healthcheck" | ||
46 | FEDI_LOGIN_CALLBACK_URL = "/checkinbot/fedi_login_callback" | ||
47 | BOT_DOMAIN = "https://zjw.social" | ||
48 | BOT_PORT = 30010 | ||
49 | BOT_SCOPE = ['read:accounts', 'write:media', 'write:statuses'] | 50 | BOT_SCOPE = ['read:accounts', 'write:media', 'write:statuses'] |
diff --git a/contrib/docker-compose.yaml b/contrib/docker-compose.yaml new file mode 100644 index 0000000..7ba8c2d --- /dev/null +++ b/contrib/docker-compose.yaml | |||
@@ -0,0 +1,13 @@ | |||
1 | version: '3' | ||
2 | services: | ||
3 | checkin.bot: | ||
4 | image: "clarkzjw/checkin.bot:latest" | ||
5 | restart: always | ||
6 | volumes: | ||
7 | - "./config.ini:/usr/src/app/config.ini" | ||
8 | - sqlite3:/usr/src/app/database/ | ||
9 | ports: | ||
10 | - "8080:8080" | ||
11 | |||
12 | volumes: | ||
13 | sqlite3: | ||
diff --git a/dbstore/peewee_store.py b/dbstore/peewee_store.py index c8d9c22..d05c642 100644 --- a/dbstore/peewee_store.py +++ b/dbstore/peewee_store.py | |||
@@ -5,7 +5,7 @@ TOOT_VISIBILITY_UNLISTED = "unlisted" | |||
5 | TOOT_VISIBILITY_PRIVATE = "private" | 5 | TOOT_VISIBILITY_PRIVATE = "private" |
6 | 6 | ||
7 | 7 | ||
8 | db = SqliteDatabase("checkinbot.db") | 8 | db = SqliteDatabase("database/checkinbot.db") |
9 | db.connect(reuse_if_open=True) | 9 | db.connect(reuse_if_open=True) |
10 | 10 | ||
11 | 11 | ||
diff --git a/requirements.txt b/requirements.txt index d1e0036..39887b9 100644 --- a/requirements.txt +++ b/requirements.txt | |||
@@ -1,12 +1,10 @@ | |||
1 | anyio==3.6.2 | 1 | anyio==3.6.2 |
2 | APScheduler==3.10.0 | 2 | APScheduler==3.10.0 |
3 | asgiref==3.6.0 | ||
4 | blurhash==1.1.4 | 3 | blurhash==1.1.4 |
5 | certifi==2022.12.7 | 4 | certifi==2022.12.7 |
6 | cffi==1.15.1 | 5 | cffi==1.15.1 |
7 | charset-normalizer==3.0.1 | 6 | charset-normalizer==3.0.1 |
8 | click==8.1.3 | 7 | click==8.1.3 |
9 | crypto==1.4.1 | ||
10 | cryptography==39.0.1 | 8 | cryptography==39.0.1 |
11 | decorator==5.1.1 | 9 | decorator==5.1.1 |
12 | greenlet==2.0.2 | 10 | greenlet==2.0.2 |
@@ -18,24 +16,18 @@ httpx==0.23.3 | |||
18 | hyperframe==6.0.1 | 16 | hyperframe==6.0.1 |
19 | idna==3.4 | 17 | idna==3.4 |
20 | Mastodon.py @ git+https://cgit.jinwei.me/clarkzjw/mastodon.py@503d58d226c52901532067d3dcb5a7814699f7fb | 18 | Mastodon.py @ git+https://cgit.jinwei.me/clarkzjw/mastodon.py@503d58d226c52901532067d3dcb5a7814699f7fb |
21 | Naked==0.1.32 | ||
22 | peewee==3.15.4 | 19 | peewee==3.15.4 |
23 | Pillow==9.4.0 | ||
24 | pycparser==2.21 | 20 | pycparser==2.21 |
25 | pycrypto==2.6.1 | ||
26 | python-dateutil==2.8.2 | 21 | python-dateutil==2.8.2 |
27 | python-magic==0.4.27 | 22 | python-magic==0.4.27 |
28 | python-telegram-bot==20.1 | 23 | python-telegram-bot==20.1 |
29 | pytz==2022.7.1 | 24 | pytz==2022.7.1 |
30 | pytz-deprecation-shim==0.1.0.post0 | 25 | pytz-deprecation-shim==0.1.0.post0 |
31 | PyYAML==6.0 | ||
32 | requests==2.28.2 | 26 | requests==2.28.2 |
33 | rfc3986==1.5.0 | 27 | rfc3986==1.5.0 |
34 | shellescape==3.8.1 | ||
35 | six==1.16.0 | 28 | six==1.16.0 |
36 | sniffio==1.3.0 | 29 | sniffio==1.3.0 |
37 | SQLAlchemy==2.0.4 | 30 | SQLAlchemy==2.0.4 |
38 | sqlparse==0.4.3 | ||
39 | starlette==0.25.0 | 31 | starlette==0.25.0 |
40 | typing_extensions==4.5.0 | 32 | typing_extensions==4.5.0 |
41 | tzdata==2022.7 | 33 | tzdata==2022.7 |