Skip to content

Commit 3232c20

Browse files
committed
feat: add slim deploy
1 parent 8edca20 commit 3232c20

File tree

13 files changed

+57
-11
lines changed

13 files changed

+57
-11
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ cython_debug/
175175
.ruff_cache
176176
.uv_cache
177177

178-
deploy/dev/tgdb/clients/*
179-
!deploy/dev/tgdb/clients/.gitkeep
178+
deploy/common/tgdb/clients/*
179+
!deploy/common/tgdb/clients/.gitkeep
180180
*.session
181181

182182
x.py
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1ApWapygAUL4h-ZQyV1pP-Cadjpayas3tMlzIzwN6RMnAnkp9t0egUiXsid8uURsYWLkbBuPFeDnQQfXusd3vYYmzyrxIsK0K4UCTBjgmt8xEL7yY6DKhxWFrlnQNgTMqefqC9U6aber7oxJeku_GCTd1rDPTeT4jDSuTvKqDcGnqH-jJBEV-0Csh_5IzHcaGbPy7bQ9SbEAgf_slgUWAiVBAXaTFPKdxS-gogaqmF23sBgbwUg7N-tI7z1467RvQMvdcFRdLLrOA6Ptc1QUYIRDfLrTX1HkBS3BOid4dqeP3JYoA-UjHg8L4JADtUqK2aqLZvy9FqFEt3j0mwlnB-peKvXXb64g=
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1ApWapygAUAOnICU2Zxtk05j7WWwDTkj8ym85iUXikiWQdnLrcfmr4OH1MY_VcjflbC1QTtRYdfI9myuu00tsOhZ2pK6Fq_6EtQ9ghrNHdvkH5mOfkGetaZiOqqriZcphF63BaecoRJJ6395Z5d2Xlb5XvtaivS9zp3dN--J4pO8fO2ryeLTRrudt_u_oenI3RWJ_BZHumLZzjzTBbHLzB9aE4gPjltKzGABAjS5kZTIzuYMJ0EpX-mF7ta1X_Bacroh4XxCjUwrXyOYPQASPxA3bsasJwi5jd6y1hXV47Y6OVxl1uel6GBiAEnnM031CC4kC9IKq02SUMQsrjucSozDaJkOQGf0=
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ conf:
88
hash: "6d9d7305ffc6f148dab120d24541b127"
99

1010
clients:
11-
bots: "/app/deploy/dev/tgdb/clients/bots.txt"
12-
userbots: "/app/deploy/dev/tgdb/clients/userbots.txt"
11+
bots: "/etc/tgdb/clients/bots.txt"
12+
userbots: "/etc/tgdb/clients/userbots.txt"
1313

1414
horizon:
15-
max_len: 10_000
15+
max_len: 3_000
1616
transaction:
17-
max_age_seconds: 120
17+
max_age_seconds: 30
1818

1919
message_cache:
2020
max_len: 1_000_000

deploy/dev/docker-compose.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ services:
1111
- "tgdb:dev"
1212
volumes:
1313
- ../..:/app
14+
- ../../deploy/common/tgdb/config:/etc/tgdb
1415
- tgdb-data:/run/app
1516
environment:
16-
CONF_PATH: /app/deploy/dev/tgdb/conf.yaml
17+
CONFIG_PATH: /etc/tgdb/config.yaml
1718
ports:
1819
- 8000:8000
1920
command: tgdb-dev
21+
healthcheck:
22+
test: python3 -c "from urllib.request import urlopen as f; assert f('http://tgdb:8000/health').status == 204"
23+
start_period: 2m
24+
start_interval: 0.5s
25+
interval: 10s
2026

2127
volumes:
2228
tgdb-data: null

deploy/slim/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS wheel
2+
3+
WORKDIR /run/build
4+
ENV UV_COMPILE_BYTECODE=1
5+
6+
COPY . .
7+
RUN uv build --wheel --no-python-downloads
8+
9+
10+
FROM python:3.13-slim-bookworm AS tgdb
11+
12+
WORKDIR /run/app
13+
14+
COPY --from=wheel /run/build/dist dist
15+
RUN pip install dist/* && rm dist -fr
16+
CMD ["tgdb"]

deploy/slim/docker-compose.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: tgdb
2+
3+
services:
4+
tgdb:
5+
image: tgdb:slim
6+
container_name: tgdb
7+
build:
8+
context: ../../
9+
dockerfile: deploy/slim/Dockerfile
10+
tags:
11+
- "tgdb:slim"
12+
volumes:
13+
- ../../deploy/common/tgdb/config:/etc/tgdb
14+
environment:
15+
CONFIG_PATH: /etc/tgdb/config.yaml
16+
ports:
17+
- 8000:8000
18+
healthcheck:
19+
test: python3 -c "from urllib.request import urlopen as f; assert f('http://tgdb:8000/health').status == 204"
20+
start_period: 2m
21+
start_interval: 0.5s
22+
interval: 10s

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ build-backend = "hatchling.build"
4545
packages = ["src/tgdb"]
4646

4747
[project.scripts]
48-
tgdb = "tgdb.main.prod_server.__main__:main"
48+
tgdb = "tgdb.main.slim_server.__main__:main"
4949
tgdb-dev = "tgdb.main.dev_server.__main__:main"
5050

5151
[tool.mypy]

src/tgdb/infrastructure/typenv/envs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
@dataclass(frozen=True)
88
class Envs:
9-
conf_path: Path
9+
config_path: Path
1010

1111
@classmethod
1212
def load(cls) -> "Envs":
1313
env = typenv.Env()
1414

1515
return Envs(
16-
conf_path=Path(env.str("CONF_PATH")),
16+
config_path=Path(env.str("CONFIG_PATH")),
1717
)

0 commit comments

Comments
 (0)