docker之ffmpeg多阶段构建

语言: CN / TW / HK

1. 首先我们把mwader/static-ffmpeg作为基础镜像

FROM mwader/static-ffmpeg:4.3

2. 构建时增加一步就可以了

COPY --from=mwader/static-ffmpeg:4.3 /ffmpeg /ffprobe /usr/local/bin/

完整例子

FROM mwader/static-ffmpeg:4.3 as stage-1
FROM node:14-buster as stage-2

WORKDIR /opt
COPY package*.json ./
RUN npm install --registry=https://registry.npm.taobao.org

FROM node:14-alpine

WORKDIR /opt

COPY --from=stage-1 /ffmpeg /ffprobe /usr/local/bin/
COPY --from=stage-2 /opt/node_modules /opt/node_modules
COPY . .

EXPOSE 80

CMD [ "node", "index.js" ]