I need to use ffmpeg in a Node.js application that runs in a docker container (created using docker-compose). I'm very new to Docker, and would like to know how to command Docker to install ffmpeg when creating the image.
DockerFile
FROM node:carbon
WORKDIR /usr/src/app
# where available (npm@5+)
COPY package*.json ./
RUN npm install -g nodemon
RUN npm install --only=production
COPY . .
EXPOSE 3000
CMD [ "npm", "start" ]
package.json:
{
"name": "radcast-apis",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node ./bin/www",
"dev": "nodemon --inspect-brk=0.0.0.0:5858 ./bin/www"
},
"dependencies": {
"audioconcat": "^0.1.3",
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"express": "~4.16.0",
"firebase-admin": "^5.12.1",
"http-errors": "~1.6.2",
"jade": "~1.11.0",
"morgan": "~1.9.0"
},
"devDependencies": {
"nodemon": "^1.11.0"
}
}
docker-compose.yml:
version: "2"
services:
web:
volumes:
- "./app:/src/app"
build: .
command: npm run dev
ports:
- "3000:3000"
- "5858:5858"
If it helps anyone, I figured out a way.
"ffmpeg-static": "^2.3.0"
, this makes the binary files available in the docker container. ffmpeg_static = require('ffmpeg-static')
and then inspecting the path
property on ffmpeg_static
, you can see where the binaries are in the container.ENV PATH="/your/path/to/node_modules/ffmpeg-static/bin/linux/x64:${PATH}"
That worked a trick for us! The answer that saved us was an analogous use-case for firebase cloud functions - here.