diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5c76da0a..bd9e1937 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,6 +55,7 @@ repos: entry: 'console\.log' exclude: | (?x)^( + entrypoint.sh| .pre-commit-config.yaml| ^src/core/engines/webjs/session.webjs.core.ts| )$ diff --git a/Dockerfile b/Dockerfile index 6eb3ba61..365687e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -86,6 +86,7 @@ COPY package.json ./ COPY --from=build /src/node_modules ./node_modules COPY --from=build /src/dist ./dist COPY --from=dashboard /dashboard ./dist/dashboard +COPY entrypoint.sh /entrypoint.sh # Chokidar options to monitor file changes ENV CHOKIDAR_USEPOLLING=1 @@ -96,4 +97,4 @@ ENV WAHA_ZIPPER=ZIPUNZIP # Run command, etc EXPOSE 3000 -CMD yarn start:prod +CMD ["/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 00000000..2da8ce13 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# Calculate UV_THREADPOOL_SIZE based on number of CPUs +cpus=$(node -e "const os = require('os'); console.log(os.cpus().length);") +uv_threadpool_size=$(($cpus * 2)) + +# Set UV_THREADPOOL_SIZE as an environment variable +export UV_THREADPOOL_SIZE="${UV_THREADPOOL_SIZE:-$uv_threadpool_size}" + +# Start your application using yarn +yarn start:prod