mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-21 11:26:39 +00:00
core: let teams deploy discord bot as a single container
This commit is contained in:
12
packages/discord/.dockerignore
Normal file
12
packages/discord/.dockerignore
Normal file
@@ -0,0 +1,12 @@
|
||||
node_modules
|
||||
dist
|
||||
.turbo
|
||||
|
||||
.env
|
||||
.env.*
|
||||
|
||||
*.sqlite
|
||||
*.sqlite-shm
|
||||
*.sqlite-wal
|
||||
|
||||
.git
|
||||
@@ -1,6 +1,6 @@
|
||||
# Discord
|
||||
DISCORD_TOKEN=
|
||||
DATABASE_PATH=discord.sqlite # SQLite file path
|
||||
DATABASE_PATH=discord.sqlite # SQLite file path (use /data/discord.sqlite in Docker)
|
||||
ALLOWED_CHANNEL_IDS= # Comma-separated Discord channel IDs
|
||||
DISCORD_ROLE_ID= # Role ID that triggers the bot (optional, for @role mentions)
|
||||
DISCORD_CATEGORY_ID= # Optional category ID that is allowed
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
# Stage 1: Install dependencies
|
||||
FROM oven/bun:1.2-alpine AS deps
|
||||
WORKDIR /app
|
||||
COPY package.json bun.lock* ./
|
||||
COPY web/package.json web/
|
||||
COPY discord-bot/package.json discord-bot/
|
||||
RUN bun install --frozen-lockfile
|
||||
FROM oven/bun:1.3.9-alpine
|
||||
|
||||
# Stage 2: Production image
|
||||
FROM oven/bun:1.2-alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json bun.lock* ./
|
||||
COPY web/package.json web/
|
||||
COPY discord-bot/package.json discord-bot/
|
||||
RUN bun install --production --frozen-lockfile
|
||||
COPY package.json ./
|
||||
RUN bun install --production
|
||||
|
||||
# Copy shared DB schema (discord-bot imports from main project)
|
||||
COPY src/db/schema.ts src/db/schema.ts
|
||||
COPY src ./src
|
||||
|
||||
# Copy discord bot source
|
||||
COPY discord-bot/src/ discord-bot/src/
|
||||
ENV NODE_ENV=production
|
||||
ENV DATABASE_PATH=/data/discord.sqlite
|
||||
ENV HEALTH_HOST=0.0.0.0
|
||||
ENV HEALTH_PORT=8787
|
||||
|
||||
CMD ["bun", "run", "discord-bot/src/index.ts"]
|
||||
RUN mkdir -p /data
|
||||
|
||||
VOLUME ["/data"]
|
||||
EXPOSE 8787
|
||||
|
||||
CMD ["bun", "run", "src/index.ts"]
|
||||
|
||||
@@ -44,6 +44,33 @@ bun run db:init
|
||||
bun run dev
|
||||
```
|
||||
|
||||
### 4. Run with Docker
|
||||
|
||||
Build the image from the package directory (or from repo root using the same path as context):
|
||||
|
||||
```bash
|
||||
docker build -t opencode-discord packages/discord
|
||||
```
|
||||
|
||||
Create an env file from the template and set the required values (`DISCORD_TOKEN`, `DAYTONA_API_KEY`, `OPENCODE_ZEN_API_KEY`):
|
||||
|
||||
```bash
|
||||
cp packages/discord/.env.example .env
|
||||
```
|
||||
|
||||
Run the container with a persistent volume for SQLite data:
|
||||
|
||||
```bash
|
||||
docker run --name opencode-discord \
|
||||
--env-file .env \
|
||||
-e DATABASE_PATH=/data/discord.sqlite \
|
||||
-p 8787:8787 \
|
||||
-v opencode-discord-data:/data \
|
||||
opencode-discord
|
||||
```
|
||||
|
||||
This image does not require Docker Compose or special network wiring; only outbound access to Discord, Daytona, and OpenCode APIs.
|
||||
|
||||
### Environment Variables
|
||||
|
||||
#### Required
|
||||
|
||||
Reference in New Issue
Block a user