Skip to content

Commit

Permalink
docker: download files first to hopefully not break cache
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Oct 19, 2024
1 parent 151b46a commit 11189c1
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions Dockerfile.ffmpeg-static-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# To build release:
# docker buildx build -f Dockerfile.ffmpeg-static-alpine -t ghcr.io/hybridgroup/ffmpeg:5.16-alpine --platform=linux/arm64,linux/amd64 --load .

# Stage 1: Build OpenCV
# linux/amd64 build
FROM --platform=linux/amd64 alpine:3.20 AS builder-amd64

WORKDIR /
Expand Down Expand Up @@ -65,9 +65,28 @@ RUN cd ffmpeg-${FFMPEG_VERSION} && \
--enable-static --disable-shared --enable-gpl --enable-libx264 --enable-libvpx --enable-zlib \
--disable-sdl2 --disable-vaapi --disable-vdpau --disable-v4l2-m2m --disable-doc && \
make -j $(nproc --all) && make install



# linux/arm64 build
FROM --platform=linux/arm64 alpine:3.20 AS builder-arm64

WORKDIR /

ARG FFMPEG_VERSION=5.1.6
ARG XZ_VERSION=5.6.3

# download xz
RUN wget -O xz-${XZ_VERSION}.tar.bz2 "https://github.com/tukaani-project/xz/releases/download/v${XZ_VERSION}/xz-${XZ_VERSION}.tar.bz2" && \
tar -xf xz-${XZ_VERSION}.tar.bz2

# download bzip2
RUN wget -O bzip2-master.tar.bz2 "https://gitlab.com/bzip2/bzip2/-/archive/master/bzip2-master.tar.bz2" && \
tar -xf bzip2-master.tar.bz2

# download ffmpeg source
RUN wget -O ffmpeg-5.0.tar.bz2 "https://www.ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2" && \
tar -xf ffmpeg-5.0.tar.bz2

# Install dependencies
RUN apk update && apk add --no-cache \
build-base \
Expand All @@ -87,26 +106,16 @@ RUN apk update && apk add --no-cache \
opus-dev dav1d-dev python3

# Build and install xz
RUN wget -O xz-${XZ_VERSION}.tar.bz2 "https://github.com/tukaani-project/xz/releases/download/v${XZ_VERSION}/xz-${XZ_VERSION}.tar.bz2" && \
tar -xf xz-${XZ_VERSION}.tar.bz2

RUN cd xz-${XZ_VERSION} && \
./configure --disable-shared && \
make && make install

# Build and install bzip2
RUN wget -O bzip2-master.tar.bz2 "https://gitlab.com/bzip2/bzip2/-/archive/master/bzip2-master.tar.bz2" && \
tar -xf bzip2-master.tar.bz2

RUN cd bzip2-master && \
mkdir build && cd build && \
cmake .. -DCMAKE_BUILD_TYPE="Release" -DENABLE_STATIC_LIB=ON -DENABLE_LIB_ONLY=ON && \
cmake --build . --target install

# Build and install ffmpeg
RUN wget -O ffmpeg-5.0.tar.bz2 "https://www.ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2" && \
tar -xf ffmpeg-5.0.tar.bz2

# Build and install libvpx
RUN cd ffmpeg-${FFMPEG_VERSION} && \
git -C libvpx pull 2> /dev/null || git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \
Expand Down

0 comments on commit 11189c1

Please sign in to comment.