Skip to content

Commit

Permalink
docker: do not expose ports by default (#284)
Browse files Browse the repository at this point in the history
* docker: do not expose ports by default

* bump version

---------

Co-authored-by: JamzumSum <zzzzss990315@gmail.com>
  • Loading branch information
github-actions[bot] and JamzumSum authored Dec 15, 2023
1 parent d31aa9e commit 8c8dd0e
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 257 deletions.
2 changes: 1 addition & 1 deletion doc/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ Qzone3TG 支持从环境变量中读取配置。:program:`docker-compose` 的配

.. literalinclude:: ../../docker/docker-compose.yml
:language: yaml
:emphasize-lines: 10-15
:emphasize-lines: 6-14
1 change: 0 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ LABEL org.opencontainers.image.source=https://github.com/aioqzone/Qzone2TG
LABEL org.opencontainers.image.description "Forward Qzone feeds to telegram."
LABEL org.opencontainers.image.licenses=AGPL-3.0-or-later

EXPOSE 80 88 443 8443
WORKDIR /app
ENV PATH="/app:$PATH"
ENV PYTHONPATH="/app:$PYTHONPATH"
Expand Down
10 changes: 5 additions & 5 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
version: "3"
services:
qzone:
container_name: qzone
image: ghcr.io/aioqzone/qzone3tg:latest
image: ghcr.io/aioqzone/qzone3tg:latest-beta
environment:
# ${xxx}表示变量。您可以直接将变量替换为字面值
# ${xxx}表示环境变量。您可以直接将变量替换为字面值
# 也可以在 .env 文件中定义这些变量,如
# xxx=123
password: ${PASSWD}
Expand All @@ -14,10 +13,11 @@ services:
bot.storage.database: data/${UIN}.db
# bot.network.proxy: socks5://host.docker.internal:7890
# network_mode: host
expose: [80]
volumes:
- ./log:/app/log
- /var/log/Qzone2TG:/app/log
- ./config:/app/config:ro
- qzone-data:/app/data
# - ./data:/app/data # choose a syntax as you like

volumes:
qzone-data:
359 changes: 115 additions & 244 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Qzone3TG"
version = "0.9.6.dev10"
version = "0.9.7.dev1"
description = "Forward Qzone feeds to telegram."
authors = ["aioqzone <zzzzss990315@gmail.com>"]
readme = "README.md"
Expand Down Expand Up @@ -39,7 +39,7 @@ optional = true
[tool.poetry.group.dev.dependencies]
pre-commit = "*"
black = "^23.1.0"
isort = ">=5.13.0"
isort = ">=5.13.1"

[tool.poetry.group.docs]
optional = true
Expand Down
2 changes: 2 additions & 0 deletions src/qzone3tg/app/interact/_conversation/emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ async def _get_eid_bytes(self: InteractApp, eid: int) -> BufferedInputFile | Non
for ext in ("gif", "jpg", "png"):
try:
async with self.client.get(build_html(eid, ext=ext)) as r:
if r.content_length and r.content_length <= 43:
continue
return BufferedInputFile(await r.content.read(), f"e{eid}.{ext}")
except:
pass
Expand Down
11 changes: 7 additions & 4 deletions src/qzone3tg/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ class WebhookConf(BaseModel):
"""webhook 端口. 在此端口上设置一个小型的服务器用于监听请求. 用户需要保证 `!telegram api` 可以直接请求此端口,
或经反向代理等中间环节间接访问此端口.
受 Telegram :obj:`限制 <SUPPORTED_WEBHOOK_PORTS>`, 端口只能在 443, 80, 88, 8443 中选择。
.. versionchanged:: 0.9.7.dev1
端口不再局限于规定端口(443, 80, 88, 8443)。此时用户必须将规定端口上的流量转发至 :obj:`.port` 所指定的端口。
"""

cert: FilePath | None = None
Expand All @@ -106,10 +108,11 @@ class WebhookConf(BaseModel):
.. versionadded:: 0.5.0a3
"""

@field_validator("port")
@field_validator("destination")
@classmethod
def port_choice(cls, v: int):
assert v in SUPPORTED_WEBHOOK_PORTS
def port_choice(cls, v: Url):
if v.port is not None:
assert v.port in SUPPORTED_WEBHOOK_PORTS
return v


Expand Down

0 comments on commit 8c8dd0e

Please sign in to comment.