Skip to content

Commit

Permalink
opt: optimize script, reduce layer
Browse files Browse the repository at this point in the history
  • Loading branch information
nidbCN committed Nov 15, 2024
1 parent febb040 commit fb24416
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN cp /etc/apt/sources.list.d/debian.sources /tmp/debian.sources.bak && \
mv /tmp/debian.sources.bak /etc/apt/sources.list.d/debian.sources

# a future that my docker will copy the file behind soft link.
COPY ["./ffmpeg/lib/libavcodec.so.61", "./ffmpeg/lib/libavdevice.so.61", "./ffmpeg/lib/libavfilter.so.10", "./ffmpeg/lib/libavformat.so.61", "./ffmpeg/lib/libavutil.so.59", "./ffmpeg/lib/libswresample.so.5","./ffmpeg/lib/libswscale.so.8" ,"/usr/lib/x86_64-linux-gnu/"]
COPY ./ffmpeg/lib/*.so.* /usr/lib/x86_64-linux-gnu/

27 changes: 25 additions & 2 deletions build-base.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
echo "Start make temp dir"
mkdir -p /tmp/bot_build_temp

echo "Start check download cache"
if [ ! -f "/tmp/bot_build_temp/ffmpeg-n7.0.2-6-g7e69129d2f-linux64-gpl-shared-7.0.tar.xz" ]; then
echo "File not found. Downloading..."
echo "Start download ffmpeg"
wget -O /tmp/bot_build_temp/ffmpeg-n7.0.2-6-g7e69129d2f-linux64-gpl-shared-7.0.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-08-31-12-50/ffmpeg-n7.0.2-6-g7e69129d2f-linux64-gpl-shared-7.0.tar.xz"
fi

echo "Start make local temp dir"
mkdir -p ffmpeg

tar --strip-components=1 -xf /tmp/bot_build_temp/ffmpeg-n7.0.2-6-g7e69129d2f-linux64-gpl-shared-7.0.tar.xz -C ffmpeg
echo "Start decompress ffmpeg"
tar --strip-components=1 -xf /tmp/bot_build_temp/ffmpeg-n7.0.2-6-g7e69129d2f-linux64-gpl-shared-7.0.tar.xz -C ./ffmpeg
echo "End decompress"

echo "Start process so files"
rm ./ffmpeg/lib/*.so
rm -r ./ffmpeg/lib/pkgconfig

for file in ./ffmpeg/lib/*.so.*; do
if [ -L "$file" ]; then
target=$(readlink "$file")
rm "$file"
mv "./ffmpeg/lib/$target" "$file"
fi
done

ls -l ./ffmpeg/lib
echo "End process"

echo "Start build docker image"
sudo docker build . -f Dockerfile.base -t registry.cn-beijing.aliyuncs.com/nidb-cr/camera-capture-bot-base:7.0.2-6
echo "End build"

echo "Start clean resources"
rm -r ffmpeg

0 comments on commit fb24416

Please sign in to comment.