feat: update AI model in AskCommand and add Docker support files for improved deployment
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
node_modules
|
||||
npm-debug.log
|
||||
coverage
|
||||
.git
|
||||
.gitignore
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
*.md
|
||||
README.md
|
||||
LICENSE
|
||||
TESTING.md
|
||||
PRIVACY.md
|
||||
TERMS.md
|
||||
SECURITY.md
|
||||
ansible-README.md
|
||||
__tests__
|
||||
jest.config.js
|
||||
jest.setup.js
|
||||
.eslintrc.*
|
||||
.prettierrc
|
||||
.vscode
|
||||
.idea
|
||||
*.log
|
||||
.DS_Store
|
||||
inventory.ini
|
||||
playbook.yml
|
||||
@@ -0,0 +1,155 @@
|
||||
# Docker Setup Guide
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Docker installed on your system
|
||||
- Docker Compose (optional, but recommended)
|
||||
|
||||
## Configuration
|
||||
|
||||
1. Create a `.env` file in the project root with your Discord bot credentials:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
2. Edit the `.env` file and add your Discord bot token and other credentials:
|
||||
```
|
||||
DISCORD_TOKEN=your_discord_bot_token_here
|
||||
CLIENT_ID=your_client_id_here
|
||||
OPENROUTER_API_KEY=your_openrouter_api_key_here
|
||||
```
|
||||
|
||||
## Running with Docker Compose (Recommended)
|
||||
|
||||
### Start the bot:
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### View logs:
|
||||
|
||||
```bash
|
||||
docker-compose logs -f
|
||||
```
|
||||
|
||||
### Stop the bot:
|
||||
|
||||
```bash
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
### Restart the bot:
|
||||
|
||||
```bash
|
||||
docker-compose restart
|
||||
```
|
||||
|
||||
### Rebuild and start (after code changes):
|
||||
|
||||
```bash
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
## Running with Docker directly
|
||||
|
||||
### Build the image:
|
||||
|
||||
```bash
|
||||
docker build -t kekbot:latest .
|
||||
```
|
||||
|
||||
### Run the container:
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name kekbot \
|
||||
--env-file .env \
|
||||
--restart unless-stopped \
|
||||
kekbot:latest
|
||||
```
|
||||
|
||||
### View logs:
|
||||
|
||||
```bash
|
||||
docker logs -f kekbot
|
||||
```
|
||||
|
||||
### Stop the container:
|
||||
|
||||
```bash
|
||||
docker stop kekbot
|
||||
docker rm kekbot
|
||||
```
|
||||
|
||||
## Deploy Commands
|
||||
|
||||
Before running the bot for the first time, you may need to deploy slash commands:
|
||||
|
||||
```bash
|
||||
# Using Docker Compose
|
||||
docker-compose run --rm kekbot npm run deploy
|
||||
|
||||
# Using Docker directly
|
||||
docker run --rm --env-file .env kekbot:latest npm run deploy
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Check if container is running:
|
||||
|
||||
```bash
|
||||
docker ps
|
||||
```
|
||||
|
||||
### View all containers (including stopped):
|
||||
|
||||
```bash
|
||||
docker ps -a
|
||||
```
|
||||
|
||||
### Access container shell:
|
||||
|
||||
```bash
|
||||
docker exec -it kekbot sh
|
||||
```
|
||||
|
||||
### View container resource usage:
|
||||
|
||||
```bash
|
||||
docker stats kekbot
|
||||
```
|
||||
|
||||
## Production Considerations
|
||||
|
||||
1. **Security**: Ensure your `.env` file is never committed to version control
|
||||
2. **Logging**: Configure log rotation if using volume mounts for logs
|
||||
3. **Updates**: Regularly update the base image and dependencies
|
||||
4. **Monitoring**: Consider adding monitoring tools like Prometheus or Grafana
|
||||
5. **Backups**: If you add persistent data, implement backup strategies
|
||||
|
||||
## Multi-stage Build (Alternative)
|
||||
|
||||
For a smaller production image, you can use the multi-stage Dockerfile variant:
|
||||
|
||||
```dockerfile
|
||||
# Development stage
|
||||
FROM node:20-alpine AS development
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
|
||||
# Production stage
|
||||
FROM node:20-alpine AS production
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci --only=production
|
||||
COPY . .
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S nodejs -u 1001 && \
|
||||
chown -R nodejs:nodejs /app
|
||||
USER nodejs
|
||||
CMD ["npm", "start"]
|
||||
```
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
# Use Node.js LTS version
|
||||
FROM node:20-alpine
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy application files
|
||||
COPY . .
|
||||
|
||||
# Create a non-root user to run the application
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S nodejs -u 1001 && \
|
||||
chown -R nodejs:nodejs /app
|
||||
|
||||
# Switch to non-root user
|
||||
USER nodejs
|
||||
|
||||
# Expose port (if needed for health checks)
|
||||
EXPOSE 3000
|
||||
|
||||
# Start the bot
|
||||
CMD ["npm", "start"]
|
||||
+1
-3
@@ -48,9 +48,7 @@ export default class AskCommand extends Command {
|
||||
const response = await axios.post(
|
||||
'https://openrouter.ai/api/v1/chat/completions',
|
||||
{
|
||||
model: webSearchEnabled
|
||||
? 'google/gemma-3-27b-it:free:online'
|
||||
: 'google/gemma-3-27b-it:free',
|
||||
model: webSearchEnabled ? 'xiaomi/mimo-v2-flash:free:online' : 'xiaomi/mimo-v2-flash:free',
|
||||
messages: [
|
||||
{
|
||||
role: 'system',
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
kekbot:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: kekbot
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
# Mount logs directory if you want to persist logs
|
||||
- ./logs:/app/logs
|
||||
# Uncomment if you need to expose a port for health checks
|
||||
# ports:
|
||||
# - "3000:3000"
|
||||
# Health check (optional)
|
||||
healthcheck:
|
||||
test: ["CMD", "node", "-e", "process.exit(0)"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
Reference in New Issue
Block a user