Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile or docker-compose.yml - decrease starting friction #52

Open
voarsh2 opened this issue Feb 11, 2023 · 7 comments
Open

Dockerfile or docker-compose.yml - decrease starting friction #52

voarsh2 opened this issue Feb 11, 2023 · 7 comments

Comments

@voarsh2
Copy link

voarsh2 commented Feb 11, 2023

You might get more people using this if you packaged it in a nice Dockerfile or docker-compose.yml file to easily have everything installed/packaged.

@ahyear
Copy link

ahyear commented Feb 27, 2023

I am trying to make a docker image .
I seems ok but when I start it i hav an error:
FROM debian:bullseye

RUN apt update && apt install nodejs npm nginx ffmpeg software-properties-common python curl python3 python3.9 python3-pip python3.9-distutils python3.9-dev pkg-config libicu-dev lsof nano -y 
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1000
RUN pip3 install setuptools-rust
RUN pip3 install --upgrade setuptools
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
RUN alias pip=pip3
RUN alias python=python3.9
RUN pip3 install --upgrade setuptools
RUN pip3 install git+https://github.com/openai/whisper.git
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
ENV NVM_DIR /root/.nvm
ENV SHIPPABLE_NODE_VERSION v16
RUN . $HOME/.nvm/nvm.sh && nvm install $SHIPPABLE_NODE_VERSION && nvm alias default $SHIPPABLE_NODE_VERSION && nvm use default
RUN npm install -g http-server pm2
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
RUN chmod a+rx /usr/local/bin/yt-dlp  # Make executable 
RUN git clone https://github.com/mayeaux/generate-subtitles
ENV LIBRETRANSLATE http://127.0.0.1:5000
ENV CONCURRENT_AMOUNT 2
ENV NODE_ENV production
WORKDIR 'generate-subtitles'
RUN npm install
EXPOSE 5000
EXPOSE 80
CMD npm start

and here is the error:

'''

init@0.0.0 start
node app.js
/generate-subtitles/queue/newQueue.js:34
const matchesByWebsocket = global.jobProcesses[processNumber]?.websocketNumber === websocketNumber;
^
SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/generate-subtitles/lib/websockets.js:3:50)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
npm ERR! code 1
npm ERR! path /generate-subtitles
npm ERR! command failed
npm ERR! command sh -c node app.js
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-02-27T07_59_15_784Z-debug.log
'''

@voarsh2
Copy link
Author

voarsh2 commented Feb 27, 2023

The error message suggests that there is a syntax error in the file newQueue.js at line 34, specifically, an unexpected token '.'

/generate-subtitles/queue/newQueue.js:34
const matchesByWebsocket = global.jobProcesses[processNumber]?.websocketNumber === websocketNumber;
^
SyntaxError: Unexpected token '.'

The ?. syntax is called the Optional Chaining Operator and it was introduced in Node.js version 14.3.0. It looks like the version of Node.js installed in your Dockerfile might be older than 14.3.0, hence the syntax error.

You can try upgrading your Node.js version to the latest stable release by changing this line:

ENV SHIPPABLE_NODE_VERSION v16

to

ENV SHIPPABLE_NODE_VERSION stable

This will install the latest stable version of Node.js. Alternatively, you can specify a version greater than or equal to 14.3.0 that supports the Optional Chaining Operator.

Once you've made the change, rebuild your Docker image and see if the error goes away.

@ahyear
Copy link

ahyear commented Feb 27, 2023

stangly i see a node 16 installed :

Step 14/26 : RUN . $HOME/.nvm/nvm.sh && nvm install $SHIPPABLE_NODE_VERSION && nvm alias default $SHIPPABLE_NODE_VERSION && nvm use default
 ---> Running in c625d4fdcad1
Downloading and installing node v16.19.1...
Downloading https://nodejs.org/dist/v16.19.1/node-v16.19.1-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v16.19.1 (npm v8.19.3)
Creating default alias: default -> 16 (-> v16.19.1 *)
default -> 16 (-> v16.19.1 *)
Now using node v16.19.1 (npm v8.19.3)
Removing intermediate container c625d4fdcad1
 ---> 2345dba6ae71
Step 15/26 : RUN npm install -g http-server pm2
 ---> Running in f2ca5370a8f0

but il the log i see version 12.22.12:

23 verbose stack Error: command failed
23 verbose stack     at ChildProcess.<anonymous> (/usr/share/nodejs/@npmcli/promise-spawn/index.js:64:27)
23 verbose stack     at ChildProcess.emit (events.js:314:20)
23 verbose stack     at maybeClose (internal/child_process.js:1022:16)
23 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
24 verbose pkgid init@0.0.0
25 verbose cwd /generate-subtitles
26 verbose Linux 4.4.180+
27 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
28 verbose node v12.22.12
29 verbose npm  v7.5.2
30 error code 1
31 error path /generate-subtitles
32 error command failed
33 error command sh -c node app.js
34 verbose exit 1

maybe somthing happend during npm start ?

@ahyear
Copy link

ahyear commented Feb 27, 2023

ok! found the source of the issue
here is the new docker image.:
https://gist.github.com/ahyear/a90416ea0be0b395f235efdf062b514e

I test further now if it works

@drphero
Copy link

drphero commented Mar 3, 2023

ok! found the source of the issue here is the new docker image.: https://gist.github.com/ahyear/a90416ea0be0b395f235efdf062b514e

I test further now if it works

Any luck with it?

@jeremyVignelles
Copy link

I just tested with this configuration and this works locally:

FROM debian:bullseye

RUN apt update && apt install nginx git ffmpeg software-properties-common python curl python3 python3.9 python3-pip python3.9-distutils python3.9-dev pkg-config libicu-dev lsof nano -y 
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1000
RUN pip3 install setuptools-rust
RUN pip3 install --upgrade setuptools
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
RUN alias pip=pip3
RUN alias python=python3.9
RUN pip3 install --upgrade setuptools
RUN pip3 install git+https://github.com/openai/whisper.git
ENV NVM_DIR /root/.nvm
ENV NODE_VERSION 16.19.1
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
RUN . $HOME/.nvm/nvm.sh \
 && nvm install $NODE_VERSION \
 && nvm alias default $NODE_VERSION && nvm use default && npm install -g http-server pm2
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
RUN chmod a+rx /usr/local/bin/yt-dlp  # Make executable 
RUN git clone https://github.com/mayeaux/generate-subtitles
ENV LIBRETRANSLATE http://127.0.0.1:3000
ENV CONCURRENT_AMOUNT 2
ENV NODE_ENV production
ENV UPLOAD_FILE_SIZE_LIMIT_IN_MB 10000
WORKDIR 'generate-subtitles'
RUN npm install
EXPOSE 3000
CMD npm start
# build with docker build -t freesubtitles .
# run with docker run --rm -p 3000:3000 --name generate-subtitles freesubtitles

I changed the UPLOAD_FILE_SIZE_LIMIT_IN_MB and the listen port which is 3000 by default.

It should be doable to use the nvidia GPU to speed things up, but I don't have the closed-source drivers on my computer to try it out.

@zoltansuto
Copy link

any idea how I can make it use the the nvidia cuda driver? I tried to add the nvidia runtime to the docker command but that was not enough, at least I don't see any GPU usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants