mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
feat: add Docker support — Dockerfile, docker-compose, entrypoint
This commit is contained in:
1 parent
4a436d6044
commit
799b527467
8 files changed
+373
-1
No files matched your search
@@ -0,0 +1,10 @@
|
||||
node_modules
|
||||
.git
|
||||
.gitignore
|
||||
*.md
|
||||
!README.md
|
||||
download/
|
||||
*.zip
|
||||
config.json
|
||||
docker/config.json
|
||||
docker/.env
|
||||
@@ -144,7 +144,95 @@ Below is the complete list of Remix's commands. The default prefix is `%`.
|
||||
|
||||
If you prefer to host Remix yourself, please note: **You must make it clear that your bot is an instance of Remix.** Change the bot's name and give credit in the bot's profile (e.g., *"Powered by [Remix](https://github.com/remix-bot/fluxer)"*).
|
||||
|
||||
### Prerequisites
|
||||
### Quick Start with Docker (Recommended)
|
||||
|
||||
The fastest way to self-host Remix is with Docker. Everything — the bot, MySQL, Redis, and NodeLink — runs in containers with a single command. All Docker files live in the `docker/` folder.
|
||||
|
||||
1. **Clone and configure:**
|
||||
```bash
|
||||
git clone https://github.com/remix-bot/fluxer.git
|
||||
cd fluxer/docker
|
||||
cp .env.example .env
|
||||
cp config_example.json config.json
|
||||
```
|
||||
|
||||
2. **Edit `.env`** — set your bot token and MySQL passwords.
|
||||
|
||||
3. **Edit `config.json`** — fill in your bot token, Fluxer OAuth2 credentials (if using the dashboard), and any other settings. The Docker config already points MySQL/Redis/NodeLink at the correct service hostnames.
|
||||
|
||||
4. **Start everything:**
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
5. **Check logs:**
|
||||
```bash
|
||||
docker compose logs -f bot
|
||||
```
|
||||
|
||||
That's it. The bot will start, connect to MySQL (auto-creates the settings table), connect to NodeLink, and log in to Fluxer.
|
||||
|
||||
#### Docker file structure
|
||||
|
||||
```
|
||||
docker/
|
||||
├── Dockerfile # Multi-stage build (Node 22 + FFmpeg + tini)
|
||||
├── docker-entrypoint.sh # Config validation on first boot
|
||||
├── docker-compose.yml # bot + MySQL + Redis + NodeLink
|
||||
├── config_example.json # Docker-friendly config template
|
||||
├── .env.example # Secrets template
|
||||
├── nodelink.config.json # NodeLink audio node config
|
||||
├── config.json # You create this (gitignored)
|
||||
└── .env # You create this (gitignored)
|
||||
```
|
||||
|
||||
#### Docker services
|
||||
|
||||
| Service | Container | Port | Purpose |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `bot` | remix-bot | 8080 → 80 | The Remix bot + web dashboard |
|
||||
| `mysql` | remix-mysql | — | Per-guild settings storage |
|
||||
| `redis` | remix-redis | — | Dashboard sessions + pub/sub (optional) |
|
||||
| `nodelink` | remix-nodelink | 3000 | Lavalink-compatible audio node |
|
||||
|
||||
#### Useful Docker commands
|
||||
|
||||
```bash
|
||||
# Run from the docker/ folder
|
||||
cd docker
|
||||
|
||||
# Start all services
|
||||
docker compose up -d
|
||||
|
||||
# View live bot logs
|
||||
docker compose logs -f bot
|
||||
|
||||
# Restart the bot
|
||||
docker compose restart bot
|
||||
|
||||
# Stop everything
|
||||
docker compose down
|
||||
|
||||
# Stop and delete data volumes (full reset)
|
||||
docker compose down -v
|
||||
|
||||
# Rebuild after code changes
|
||||
docker compose up -d --build bot
|
||||
```
|
||||
|
||||
#### Using `CONFIG_JSON` env var instead of a mounted file
|
||||
|
||||
If you prefer to keep your config in an environment variable (useful for CI/CD or secret managers), set `CONFIG_JSON` in your `.env`:
|
||||
|
||||
```bash
|
||||
CONFIG_JSON={"token":"YOUR_TOKEN","mysql":{"host":"mysql","port":3306,"user":"remix","password":"remix_pw","database":"remix"},"nodelink":{"host":"nodelink","port":3000,"password":"youshallnotpass"}}
|
||||
```
|
||||
|
||||
The entrypoint will write it to `/app/config.json` on first boot if no config file is mounted.
|
||||
|
||||
### Manual Installation (Without Docker)
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
- **Node.js** >= 22.0.0 (required by moonlink.js v5)
|
||||
- **MySQL** 8.0+ with JSON column support
|
||||
@@ -354,6 +442,13 @@ fluxer/
|
||||
│ ├── migrate.mjs # Legacy-to-remote settings migration script
|
||||
│ ├── runnables.mjs # Runnable task definitions
|
||||
│ └── README.md # Settings system documentation
|
||||
├── docker/ # Docker self-hosting (Dockerfile, compose, configs)
|
||||
│ ├── Dockerfile # Multi-stage build (Node 22 + FFmpeg + tini)
|
||||
│ ├── docker-entrypoint.sh # Config validation on first boot
|
||||
│ ├── docker-compose.yml # bot + MySQL + Redis + NodeLink
|
||||
│ ├── config_example.json # Docker-friendly config template
|
||||
│ ├── .env.example # Secrets template
|
||||
│ └── nodelink.config.json # NodeLink audio node config
|
||||
└── storage/
|
||||
├── defaults.json # Default per-guild settings template
|
||||
├── modules.json # Plugin module registry
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# Bot token from https://fluxer.app/developers
|
||||
BOT_TOKEN=your_bot_token_here
|
||||
|
||||
# MySQL credentials
|
||||
MYSQL_ROOT_PASSWORD=change_me_root
|
||||
MYSQL_DATABASE=remix
|
||||
MYSQL_USER=remix
|
||||
MYSQL_PASSWORD=change_me
|
||||
|
||||
# Web dashboard port mapping (host:container)
|
||||
WEB_PORT=8080
|
||||
|
||||
# NodeLink port mapping
|
||||
NODELINK_PORT=3000
|
||||
|
||||
# Timezone
|
||||
TZ=UTC
|
||||
|
||||
# Optional: paste your entire config.json as a single line (base64 or raw JSON)
|
||||
# If set, the entrypoint will write it to /app/config.json on first boot.
|
||||
# CONFIG_JSON={"token":"...","mysql":{...}}
|
||||
|
||||
# Fluxer OAuth2 (for dashboard)
|
||||
FLUXER_OAUTH_ID=
|
||||
FLUXER_OAUTH_SECRET=
|
||||
FLUXER_OAUTH_REDIRECT_URI=
|
||||
@@ -0,0 +1,43 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# ---- Builder stage: install deps ----
|
||||
FROM node:22-bookworm-slim AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json* ./
|
||||
|
||||
RUN npm ci --omit=dev 2>/dev/null || npm install --omit=dev
|
||||
|
||||
COPY . .
|
||||
|
||||
# ---- Runtime stage: minimal image with ffmpeg ----
|
||||
FROM node:22-bookworm-slim AS runtime
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
ffmpeg \
|
||||
tini \
|
||||
curl \
|
||||
&& \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN groupadd -r remix && useradd -r -g remix -d /app -s /sbin/nologin remix
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder --chown=remix:remix /app ./
|
||||
|
||||
RUN chmod +x docker/docker-entrypoint.sh && \
|
||||
mkdir -p /app/storage && chown -R remix:remix /app
|
||||
|
||||
USER remix
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
||||
CMD pgrep -f "node index.mjs" >/dev/null 2>&1 || exit 1
|
||||
|
||||
ENTRYPOINT ["/usr/bin/tini", "--", "/app/docker/docker-entrypoint.sh"]
|
||||
|
||||
CMD ["node", "index.mjs"]
|
||||
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"token": "YOUR_BOT_TOKEN_HERE",
|
||||
"prefix": "%",
|
||||
"embedColor": "0xe9196c",
|
||||
"owners": [],
|
||||
"mysql": {
|
||||
"host": "mysql",
|
||||
"port": 3306,
|
||||
"user": "remix",
|
||||
"password": "remix_pw",
|
||||
"database": "remix"
|
||||
},
|
||||
"nodelink": {
|
||||
"host": "nodelink",
|
||||
"port": 3000,
|
||||
"password": "youshallnotpass",
|
||||
"requestTimeout": 60000
|
||||
},
|
||||
"spotify": {
|
||||
"clientId": "",
|
||||
"clientSecret": ""
|
||||
},
|
||||
"lastfm": {
|
||||
"apiKey": "",
|
||||
"apiSecret": "",
|
||||
"scrobbleThreshold": 0.5,
|
||||
"scrobbleMinMs": 240000
|
||||
},
|
||||
"dashboard": {
|
||||
"enabled": false,
|
||||
"redis": {
|
||||
"url": "redis://redis:6379"
|
||||
},
|
||||
"fluxer": {
|
||||
"id": "",
|
||||
"secret": "",
|
||||
"redirectUri": ""
|
||||
}
|
||||
},
|
||||
"webPort": 80,
|
||||
"logging": {
|
||||
"enabled": true,
|
||||
"warn": true,
|
||||
"player": true,
|
||||
"inactivity": false,
|
||||
"aloneCheck": false,
|
||||
"voice247": true,
|
||||
"voiceState": false,
|
||||
"voice": false,
|
||||
"mediaplayer": false,
|
||||
"commands": true,
|
||||
"guild": true,
|
||||
"recovery": true,
|
||||
"settings": true,
|
||||
"worker": false,
|
||||
"moonlink": true,
|
||||
"dashboard": false,
|
||||
"redis": false
|
||||
},
|
||||
"timers": {
|
||||
"inactivityTimeout": 180000,
|
||||
"aloneCheckInterval": 30000,
|
||||
"aloneCheckDebounce": 500,
|
||||
"rejoin247Delay": 3000,
|
||||
"leave247RejoinDelay": 5000,
|
||||
"intentionalLeaveTTL": 10000
|
||||
},
|
||||
"presenceInterval": 30000,
|
||||
"presenceContents": [],
|
||||
"fluxer.js": {
|
||||
"timeout": 15000,
|
||||
"retries": 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
services:
|
||||
bot:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile
|
||||
container_name: remix-bot
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
- ./config.json:/app/config.json
|
||||
- ../storage:/app/storage
|
||||
environment:
|
||||
- TZ=${TZ:-UTC}
|
||||
ports:
|
||||
- "${WEB_PORT:-8080}:80"
|
||||
networks:
|
||||
- remix-net
|
||||
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
container_name: remix-mysql
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-remix_root_pw}
|
||||
MYSQL_DATABASE: ${MYSQL_DATABASE:-remix}
|
||||
MYSQL_USER: ${MYSQL_USER:-remix}
|
||||
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-remix_pw}
|
||||
volumes:
|
||||
- mysql_data:/var/lib/mysql
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD:-remix_root_pw}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
start_period: 30s
|
||||
networks:
|
||||
- remix-net
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: remix-redis
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
networks:
|
||||
- remix-net
|
||||
|
||||
nodelink:
|
||||
image: node:22-bookworm-slim
|
||||
container_name: remix-nodelink
|
||||
restart: unless-stopped
|
||||
working_dir: /nodelink
|
||||
command: sh -c "if [ ! -f package.json ]; then npm init -y && npm install @performanc/nodelink; fi; node node_modules/@performanc/nodelink/index.js || node index.js"
|
||||
environment:
|
||||
- TZ=${TZ:-UTC}
|
||||
volumes:
|
||||
- nodelink_data:/nodelink
|
||||
- ./nodelink.config.json:/nodelink/config.json:ro
|
||||
ports:
|
||||
- "${NODELINK_PORT:-3000}:3000"
|
||||
networks:
|
||||
- remix-net
|
||||
|
||||
volumes:
|
||||
mysql_data:
|
||||
nodelink_data:
|
||||
|
||||
networks:
|
||||
remix-net:
|
||||
driver: bridge
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
CONFIG_FILE="/app/config.json"
|
||||
|
||||
if [ ! -f "$CONFIG_FILE" ]; then
|
||||
if [ -n "$CONFIG_JSON" ]; then
|
||||
printf '%s' "$CONFIG_JSON" > "$CONFIG_FILE"
|
||||
echo "[Docker] Generated config.json from CONFIG_JSON env var."
|
||||
elif [ -f "/app/docker/config_example.json" ]; then
|
||||
cp /app/docker/config_example.json "$CONFIG_FILE"
|
||||
echo "[Docker] WARNING: config.json not found — copied from docker/config_example.json."
|
||||
echo "[Docker] Edit the mounted config.json and restart the container."
|
||||
else
|
||||
echo "[Docker] FATAL: config.json not found and no template available." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "node" ] && [ "$2" = "index.mjs" ]; then
|
||||
echo "[Docker] Starting Remix bot..."
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"server": {
|
||||
"port": 3000,
|
||||
"password": "youshallnotpass"
|
||||
},
|
||||
"sources": {
|
||||
"youtube": true,
|
||||
"ytmusic": true,
|
||||
"soundcloud": true,
|
||||
"deezer": true,
|
||||
"spotify": true,
|
||||
"http": true
|
||||
},
|
||||
"search": {
|
||||
"defaultSource": "ytmusic",
|
||||
"fallback": true
|
||||
},
|
||||
"audio": {
|
||||
"normalization": true
|
||||
},
|
||||
"cache": {
|
||||
"enabled": true,
|
||||
"maxSize": 536870912
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user