aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2023-02-23 22:24:05 -0800
committerclarkzjw <[email protected]>2023-02-23 22:24:05 -0800
commitaf610ab49194f12783fdfb2cc676c4877b22ed7c (patch)
treebe43b7324d06886ad1ed41a015bd356ae9320d56
parenta9fb6f252553ae49a2ba372434073824babe31e4 (diff)
downloadswarm2fediverse-af610ab49194f12783fdfb2cc676c4877b22ed7c.tar.gz
deploy: add Dockerfile and docker-compose.yaml
-rw-r--r--.dockerignore3
-rw-r--r--Dockerfile11
-rw-r--r--bot.py2
-rw-r--r--config.ini.example7
-rw-r--r--config.py11
-rw-r--r--contrib/docker-compose.yaml13
-rw-r--r--dbstore/peewee_store.py2
-rw-r--r--requirements.txt8
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
diff --git a/Dockerfile b/Dockerfile
index 2d13273..6e97ed6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1 +1,10 @@
1FROM python:3 1FROM python:3.10
2
3WORKDIR /usr/src/app
4
5COPY requirements.txt ./
6RUN pip install --no-cache-dir -r requirements.txt
7
8COPY . .
9
10CMD [ "python", "./bot.py" ]
diff --git a/bot.py b/bot.py
index 1d59f9e..b44f9df 100644
--- a/bot.py
+++ b/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 @@
2BOT_TOKEN = 2BOT_TOKEN =
3FOURSQUARE_API_KEY = 3FOURSQUARE_API_KEY =
4ENCRYPT_KEY = 4ENCRYPT_KEY =
5
6[API]
7TELEGRAM_WEBHOOK_URL = "/checkinbot/webhook"
8HEALTHCHECK_URL = "/checkinbot/healthcheck"
9FEDI_LOGIN_CALLBACK_URL = "/checkinbot/fedi_login_callback"
10BOT_DOMAIN = "https://"
11BOT_PORT = 8080
diff --git a/config.py b/config.py
index 0fae9b1..fe69bd9 100644
--- a/config.py
+++ b/config.py
@@ -10,6 +10,12 @@ BOT_TOKEN = config["DEFAULT"]["BOT_TOKEN"]
10FSQ_API_KEY = config["DEFAULT"]["FOURSQUARE_API_KEY"] 10FSQ_API_KEY = config["DEFAULT"]["FOURSQUARE_API_KEY"]
11ENCRYPT_KEY = config["DEFAULT"]["ENCRYPT_KEY"] 11ENCRYPT_KEY = config["DEFAULT"]["ENCRYPT_KEY"]
12 12
13TELEGRAM_WEBHOOK_URL = config["API"]["TELEGRAM_WEBHOOK_URL"]
14HEALTHCHECK_URL = config["API"]["HEALTHCHECK_URL"]
15FEDI_LOGIN_CALLBACK_URL = config["API"]["FEDI_LOGIN_CALLBACK_URL"]
16BOT_DOMAIN = config["API"]["BOT_DOMAIN"]
17BOT_PORT = int(config["API"]["BOT_PORT"])
18
13MEDIA_GROUP_TIMEOUT = 3 19MEDIA_GROUP_TIMEOUT = 3
14 20
15FEDI_LOGIN, WAIT_VISIBILITY, WAIT_LOCATION, LOCATION_SEARCH_KEYWORD, LOCATION_CONFIRMATION, ADD_MEDIA, ADD_COMMENT = range(7) 21FEDI_LOGIN, WAIT_VISIBILITY, WAIT_LOCATION, LOCATION_SEARCH_KEYWORD, LOCATION_CONFIRMATION, ADD_MEDIA, ADD_COMMENT = range(7)
@@ -41,9 +47,4 @@ class MsgDict(TypedDict):
41KEY_TOOT_STATUS_ID = "toot_status_id" 47KEY_TOOT_STATUS_ID = "toot_status_id"
42KEY_TOOT_STATUS_CONTENT = "toot_status_content" 48KEY_TOOT_STATUS_CONTENT = "toot_status_content"
43 49
44TELEGRAM_WEBHOOK_URL = "/checkinbot/webhook"
45HEALTHCHECK_URL = "/checkinbot/healthcheck"
46FEDI_LOGIN_CALLBACK_URL = "/checkinbot/fedi_login_callback"
47BOT_DOMAIN = "https://zjw.social"
48BOT_PORT = 30010
49BOT_SCOPE = ['read:accounts', 'write:media', 'write:statuses'] 50BOT_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 @@
1version: '3'
2services:
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
12volumes:
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"
5TOOT_VISIBILITY_PRIVATE = "private" 5TOOT_VISIBILITY_PRIVATE = "private"
6 6
7 7
8db = SqliteDatabase("checkinbot.db") 8db = SqliteDatabase("database/checkinbot.db")
9db.connect(reuse_if_open=True) 9db.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 @@
1anyio==3.6.2 1anyio==3.6.2
2APScheduler==3.10.0 2APScheduler==3.10.0
3asgiref==3.6.0
4blurhash==1.1.4 3blurhash==1.1.4
5certifi==2022.12.7 4certifi==2022.12.7
6cffi==1.15.1 5cffi==1.15.1
7charset-normalizer==3.0.1 6charset-normalizer==3.0.1
8click==8.1.3 7click==8.1.3
9crypto==1.4.1
10cryptography==39.0.1 8cryptography==39.0.1
11decorator==5.1.1 9decorator==5.1.1
12greenlet==2.0.2 10greenlet==2.0.2
@@ -18,24 +16,18 @@ httpx==0.23.3
18hyperframe==6.0.1 16hyperframe==6.0.1
19idna==3.4 17idna==3.4
20Mastodon.py @ git+https://cgit.jinwei.me/clarkzjw/mastodon.py@503d58d226c52901532067d3dcb5a7814699f7fb 18Mastodon.py @ git+https://cgit.jinwei.me/clarkzjw/mastodon.py@503d58d226c52901532067d3dcb5a7814699f7fb
21Naked==0.1.32
22peewee==3.15.4 19peewee==3.15.4
23Pillow==9.4.0
24pycparser==2.21 20pycparser==2.21
25pycrypto==2.6.1
26python-dateutil==2.8.2 21python-dateutil==2.8.2
27python-magic==0.4.27 22python-magic==0.4.27
28python-telegram-bot==20.1 23python-telegram-bot==20.1
29pytz==2022.7.1 24pytz==2022.7.1
30pytz-deprecation-shim==0.1.0.post0 25pytz-deprecation-shim==0.1.0.post0
31PyYAML==6.0
32requests==2.28.2 26requests==2.28.2
33rfc3986==1.5.0 27rfc3986==1.5.0
34shellescape==3.8.1
35six==1.16.0 28six==1.16.0
36sniffio==1.3.0 29sniffio==1.3.0
37SQLAlchemy==2.0.4 30SQLAlchemy==2.0.4
38sqlparse==0.4.3
39starlette==0.25.0 31starlette==0.25.0
40typing_extensions==4.5.0 32typing_extensions==4.5.0
41tzdata==2022.7 33tzdata==2022.7
Powered by cgit v1.2.3 (git 2.41.0)