# Deploying MelodyMuse The files in this folder are **reference templates**. MelodyMuse is a single Node.js server (`server.mjs` in the repo root) that serves the built SPA and proxies LLM calls. To deploy it you can: - Run `node server.mjs` directly (after `npm run build`) - Use the included `Dockerfile` + `docker-compose.yml` - Copy these into your Jannik-Cloud `services/melodymuse/` directory ## Required environment variables | Var | Required? | Default | Notes | |---|---|---|---| | `LLM_ENDPOINT` | **yes** | — | OpenAI-compatible base URL, e.g. `https://api.minimax.chat/v1` | | `LLM_API_KEY` | **yes** | — | Provider secret key. **Never** set this in the browser. | | `LLM_MODEL` | no | `MiniMax-M3` | Model name | | `PORT` | no | `3000` | Listen port | | `CORS_ORIGIN` | no | `*` | Set to a specific origin in production if you split SPA and server | The server refuses to start if `LLM_ENDPOINT` or `LLM_API_KEY` is missing. ## Option 1 — Bare Node ```sh # Clone, build, run git clone https://git.orfel.de/Jannik/MelodyMuse.git cd MelodyMuse npm ci npm run build # Set the secrets and start export LLM_ENDPOINT=https://api.minimax.chat/v1 export LLM_API_KEY=sk-... npm start ``` ## Option 2 — Docker ```sh # Build docker build -f deploy/Dockerfile -t melodymuse . # Run docker run --rm -p 3000:3000 \ -e LLM_ENDPOINT=https://api.minimax.chat/v1 \ -e LLM_API_KEY=sk-... \ melodymuse ``` ## Option 3 — Add to Jannik-Cloud 1. Create `services/melodymuse/` in your Jannik-Cloud repo. 2. Copy the four files from this folder into it: - `Dockerfile` - `docker-compose.yml` (rename from `docker-compose.example.yml`) - `melodymuse.caddy` - `generate-env.sh` 3. `touch services/melodymuse/service.enabled` 4. `bash services/melodymuse/generate-env.sh` — answer the prompts. 5. Commit `services/melodymuse/.env.age` and the four non-secret files. 6. `sudo bash /opt/Jannik-Cloud/deploy_script.sh` — Caddy will pick up `melodymuse.orfel.de` and route it to the container. ## Endpoints exposed by the server | Method | Path | Purpose | |---|---|---| | `GET` | `/api/health` | Health check. Returns `{ ok, llm_configured, model, endpoint }`. | | `POST` | `/api/generate` | Main generation. Body matches the `GenerateRequest` shape. | | `POST` | `/api/style/random` | Returns a one-line Suno style. Body: `{ mode: "normal" \| "crazy" }`. | | `GET` | everything else | Serves the built SPA from `dist/`, with SPA fallback to `index.html`. | ## Image footprint The runtime image is `node:20-alpine` with only `server.mjs` and the built SPA. No production `npm install` (server.mjs uses only Node built-ins). Total image size is roughly 200 MB.