mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-11 14:21:15 +00:00
Docker:
- Harden docker-compose.yml: parameterized DB creds, required AUTH_SECRET,
health checks, resource limits, network isolation, removed exposed DB port
- Add profiles (telegram/bot/full) so base 'docker compose up' needs only AUTH_SECRET
- Fix docker-entrypoint.sh: AUTH_SECRET startup guard
- Fix Dockerfile: copy prisma.config.ts + dotenv into production image
- Update .env.example with all new variables
- Update .dockerignore
Telegram Bot Service (bot/):
- TDLib-based bot using bot token auth (not HTTP Bot API)
- Commands: /search, /latest, /package, /link, /unlink, /subscribe, /unsubscribe
- pg_notify listener for send requests (bot_send) and new packages (new_package)
- Subscription-based notifications when matching packages arrive
- Dockerfile with multi-stage build (bookworm-slim for glibc/TDLib)
API & Database:
- Prisma: TelegramLink, BotSendRequest, BotSubscription models + migration
- POST /api/telegram/bot/send - queue package delivery to linked TG account
- GET /api/telegram/bot/send/[id] - poll send request status
- Server actions: generateTelegramLinkCode, unlinkTelegram, getBotSendHistory
- Worker: emit pg_notify('new_package') after creating packages
Frontend:
- Settings: TelegramLinkCard for account linking via one-time code
- STL table + drawer: SendToTelegramButton with send dialog and status polling
- Telegram admin: Bot Sends tab with delivery history table
- Shared SendHistoryRow type
README: Updated with bot docs, profiles, config vars, project structure
47 lines
1.4 KiB
Docker
47 lines
1.4 KiB
Docker
# ── Stage 1: Install production deps ─────────────────────────
|
|
FROM node:20-bookworm-slim AS deps
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
libssl-dev zlib1g-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
COPY bot/package.json bot/package-lock.json* ./
|
|
COPY prisma/ ./prisma/
|
|
|
|
# Install ALL deps (including devDependencies for tsc) and generate Prisma
|
|
RUN npm ci && npx prisma generate
|
|
|
|
# ── Stage 2: Build TypeScript ─────────────────────────────────
|
|
FROM deps AS builder
|
|
|
|
COPY bot/tsconfig.json ./
|
|
COPY bot/src/ ./src/
|
|
RUN npx tsc
|
|
|
|
# ── Stage 3: Production runner ────────────────────────────────
|
|
FROM node:20-bookworm-slim AS runner
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
libssl3 zlib1g \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy only production node_modules
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/prisma ./prisma
|
|
COPY --from=builder /app/dist ./dist
|
|
|
|
# Re-generate Prisma client
|
|
RUN npx prisma generate
|
|
|
|
RUN addgroup --system botuser && adduser --system --ingroup botuser botuser
|
|
RUN mkdir -p /data/tdlib && chown -R botuser:botuser /data/tdlib
|
|
USER botuser
|
|
|
|
VOLUME ["/data/tdlib"]
|
|
|
|
CMD ["node", "dist/index.js"]
|