ffmpeg install within existing Node.js docker image

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



ffmpeg install within existing Node.js docker image



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"




2 Answers
2



If it helps anyone, I figured out a way.


"ffmpeg-static": "^2.3.0"


ffmpeg_static = require('ffmpeg-static')


path


ffmpeg_static


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.





This worked for me! Thanks!
– GroomedGorilla
Aug 10 at 14:58



ffmpeg-static will work fine, but it means that every time you change package.json, or anything above the COPY command for package.json, you'll have to wait for the npm install command to re-download the bins.



There is another method, using multi-stage builds. This method won't require re-downloading or rebuilding ffmpeg. There are prebuilt ffmpeg images at jrottenberg/ffmpeg.



For alpine, your image would look like this...


FROM jrottenberg/ffmpeg:3.3-alpine
FROM keymetrics/node:8-alpine

# copy ffmpeg bins from first image
COPY --from=0 / /



Related question: Copy ffmpeg bins in multistage docker build






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard