[O] Dockerize

This commit is contained in:
2026-03-13 21:55:07 -04:00
parent 30e231e94e
commit 0293bdd523
3 changed files with 58 additions and 3 deletions
+24
View File
@@ -0,0 +1,24 @@
FROM python:3.13-slim
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
WORKDIR /app
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1
# Copy project requirements
COPY pyproject.toml uv.lock ./
# Install dependencies (but not the project yet)
RUN uv sync --frozen --no-install-project
# Copy the application code
COPY . .
# Install the project
RUN uv sync --frozen
# Start using uv run
CMD ["uv", "run", "python", "src/bot.py"]
+26
View File
@@ -1,4 +1,30 @@
services:
bot:
build: .
container_name: tgtree-bot
restart: unless-stopped
command: ["uv", "run", "python", "src/bot.py"]
depends_on:
- postgres
environment:
- DATABASE_URL=postgresql://cat:meow@postgres:5432/tgtree
ports:
- "127.0.0.1:9498:9498"
volumes:
- .:/app
gentree:
build: .
container_name: tgtree-gentree
restart: unless-stopped
command: ["uv", "run", "python", "src/gentree.py"]
depends_on:
- postgres
environment:
- DATABASE_URL=postgresql://cat:meow@postgres:5432/tgtree
volumes:
- .:/app
postgres:
image: postgres:latest
container_name: tgtree-db
+8 -3
View File
@@ -1,10 +1,15 @@
from peewee import Model, CharField, ForeignKeyField, IntegerField, BigIntegerField, BooleanField, CompositeKey, PostgresqlDatabase
from playhouse.db_url import connect
from utils import CONFIG
# Database configuration
db = PostgresqlDatabase('tgtree', user='cat',
password=CONFIG["db-pass"], host=CONFIG["db-host"], port=CONFIG["db-port"])
import os
# Default local connection string based on config.toml (if any)
default_db_url = CONFIG.get("db-url", "postgresql://cat:meow@127.0.0.1:5444/tgtree")
db_url = os.environ.get("DATABASE_URL", default_db_url)
db = connect(db_url)
class BaseModel(Model):