[O] Dockerize
This commit is contained in:
+24
@@ -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"]
|
||||||
@@ -1,4 +1,30 @@
|
|||||||
services:
|
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:
|
postgres:
|
||||||
image: postgres:latest
|
image: postgres:latest
|
||||||
container_name: tgtree-db
|
container_name: tgtree-db
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
from peewee import Model, CharField, ForeignKeyField, IntegerField, BigIntegerField, BooleanField, CompositeKey, PostgresqlDatabase
|
from peewee import Model, CharField, ForeignKeyField, IntegerField, BigIntegerField, BooleanField, CompositeKey, PostgresqlDatabase
|
||||||
|
from playhouse.db_url import connect
|
||||||
|
|
||||||
from utils import CONFIG
|
from utils import CONFIG
|
||||||
|
|
||||||
# Database configuration
|
import os
|
||||||
db = PostgresqlDatabase('tgtree', user='cat',
|
|
||||||
password=CONFIG["db-pass"], host=CONFIG["db-host"], port=CONFIG["db-port"])
|
# 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):
|
class BaseModel(Model):
|
||||||
|
|||||||
Reference in New Issue
Block a user