fix: use native stockfish binary via debian image
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
FROM node:lts-alpine3.20
|
FROM node:lts-bookworm-slim
|
||||||
|
|
||||||
# Install git only (stockfish via npm package)
|
# Install git and stockfish (native binary)
|
||||||
RUN apk update && apk add --no-cache git
|
RUN apt-get update && apt-get install -y --no-install-recommends git stockfish && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
ENV PNPM_HOME=/usr/local/bin
|
ENV PNPM_HOME=/usr/local/bin
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
"nanoid": "^5.0.7",
|
"nanoid": "^5.0.7",
|
||||||
"pg": "^8.12.0",
|
"pg": "^8.12.0",
|
||||||
"socket.io": "^4.7.5",
|
"socket.io": "^4.7.5",
|
||||||
"stockfish": "^16.0.0",
|
|
||||||
"xss": "^1.0.15"
|
"xss": "^1.0.15"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { spawn, ChildProcess } from "child_process";
|
import { spawn, ChildProcess } from "child_process";
|
||||||
import { createRequire } from "module";
|
|
||||||
|
|
||||||
export interface StockfishLevel {
|
export interface StockfishLevel {
|
||||||
level: number;
|
level: number;
|
||||||
@@ -31,10 +30,7 @@ export class StockfishEngine {
|
|||||||
|
|
||||||
private async init() {
|
private async init() {
|
||||||
try {
|
try {
|
||||||
const require = createRequire(import.meta.url);
|
this.process = spawn("stockfish", [], {
|
||||||
const sfPath: string = require.resolve("stockfish");
|
|
||||||
|
|
||||||
this.process = spawn(process.execPath, [sfPath], {
|
|
||||||
stdio: ["pipe", "pipe", "pipe"],
|
stdio: ["pipe", "pipe", "pipe"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user