forked from datarhei/ffmpeg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.sh
130 lines (120 loc) · 5.18 KB
/
Build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
set -au
function source_env() {
env=${1:-.env}
[ ! -f "${env}" ] && { echo "Env file ${env} doesn't exist"; return 1; }
eval $(sed -e '/^\s*$/d' -e '/^\s*#/d' -e 's/=/="/' -e 's/$/"/' -e 's/^/export /' "${env}")
}
function build_default_native() {
source_env ./Build.alpine.env
docker build \
--progress=plain \
--build-arg BUILD_IMAGE=$OS_NAME:$OS_VERSION \
--build-arg FFMPEG_VERSION=$FFMPEG_VERSION \
-f Dockerfile.alpine \
-t guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-${OS_NAME}${OS_VERSION} .
docker tag guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-${OS_NAME}${OS_VERSION} guaclive/ffmpeg:$OS_NAME-ffmpeg-$OS_VERSION-$FFMPEG_VERSION
}
function build_default() {
source_env ./Build.alpine.env
# "--load" does not support multiple platforms
# use "--push" to publish
# --platform linux/amd64,linux/arm64,linux/arm/v7
docker buildx build \
--load \
--progress=plain \
--build-arg BUILD_IMAGE=$OS_NAME:$OS_VERSION \
--build-arg FFMPEG_VERSION=$FFMPEG_VERSION \
--platform linux/amd64 \
-f Dockerfile.alpine \
-t guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-${OS_NAME}${OS_VERSION} .
docker tag guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-${OS_NAME}${OS_VERSION} guaclive/ffmpeg:$OS_NAME-ffmpeg-$OS_VERSION-$FFMPEG_VERSION
docker tag guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-${OS_NAME}${OS_VERSION} guaclive/ffmpeg:$OS_NAME-ffmpeg-latest
}
function build_rpi() {
source_env ./Build.alpine.env
source_env ./Build.alpine.rpi.env
# "--load" does not support multiple platforms
# use "--push" to publish
# --platform linux/arm64,linux/arm/v7
docker buildx build \
--load \
--progress=plain \
--build-arg BUILD_IMAGE=$OS_NAME:$OS_VERSION \
--build-arg FFMPEG_VERSION=$FFMPEG_VERSION \
--platform linux/arm64 \
-f Dockerfile.alpine.rpi \
-t guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-rpi-${OS_NAME}${OS_VERSION} .
docker tag guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-rpi-${OS_NAME}${OS_VERSION} guaclive/ffmpeg:$OS_NAME-ffmpeg-rpi-$OS_VERSION-$FFMPEG_VERSION
docker tag guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-rpi-${OS_NAME}${OS_VERSION} guaclive/ffmpeg:$OS_NAME-ffmpeg-rpi-latest
}
function build_cuda() {
source_env ./Build.ubuntu.env
source_env ./Build.ubuntu.cuda.env
docker buildx build \
--load \
--build-arg BUILD_IMAGE=nvidia/cuda:$CUDA_VERSION-devel-$OS_NAME$OS_VERSION \
--build-arg DEPLOY_IMAGE=nvidia/cuda:$CUDA_VERSION-runtime-$OS_NAME$OS_VERSION \
--build-arg FFNVCODEC_VERSION=$FFNVCODEC_VERSION \
--build-arg FREETYPE_VERSION=$FREETYPE_VERSION \
--build-arg XML2_VERSION=$XML2_VERSION \
--build-arg SRT_VERSION=$SRT_VERSION \
--build-arg X264_VERSION=$X264_VERSION \
--build-arg X265_VERSION=$X265_VERSION \
--build-arg VPX_VERSION=$VPX_VERSION \
--build-arg LAME_VERSION=$LAME_VERSION \
--build-arg OPUS_VERSION=$OPUS_VERSION \
--build-arg VORBIS_VERSION=$VORBIS_VERSION \
--build-arg FFMPEG_VERSION=$FFMPEG_VERSION \
--platform linux/amd64 \
-f Dockerfile.ubuntu.cuda \
-t guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-cuda-${OS_NAME}${OS_VERSION}-cuda${CUDA_VERSION} .
docker tag guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-cuda-${OS_NAME}${OS_VERSION}-cuda${CUDA_VERSION} guaclive/ffmpeg:$OS_NAME-ffmpeg-cuda-$OS_VERSION-$FFMPEG_VERSION-$CUDA_VERSION
docker tag guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-cuda-${OS_NAME}${OS_VERSION}-cuda${CUDA_VERSION} guaclive/ffmpeg:$OS_NAME-ffmpeg-cuda-latest
}
function build_vaapi() {
source_env ./Build.ubuntu.env
source_env ./Build.ubuntu.vaapi.env
docker buildx build \
--load \
--progress=plain \
--build-arg BUILD_IMAGE=$OS_NAME:$OS_VERSION \
--build-arg DEPLOY_IMAGE=$OS_NAME:$OS_VERSION \
--build-arg FREETYPE_VERSION=$FREETYPE_VERSION \
--build-arg XML2_VERSION=$XML2_VERSION \
--build-arg SRT_VERSION=$SRT_VERSION \
--build-arg X264_VERSION=$X264_VERSION \
--build-arg X265_VERSION=$X265_VERSION \
--build-arg VPX_VERSION=$VPX_VERSION \
--build-arg LAME_VERSION=$LAME_VERSION \
--build-arg OPUS_VERSION=$OPUS_VERSION \
--build-arg VORBIS_VERSION=$VORBIS_VERSION \
--build-arg DAV1D_VERSION=$DAV1D_VERSION \
--build-arg RAV1E_VERSION=$RAV1E_VERSION \
--build-arg FFMPEG_VERSION=$FFMPEG_VERSION \
--platform linux/amd64 \
-f Dockerfile.ubuntu.vaapi \
-t guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-vaapi-${OS_NAME}${OS_VERSION} .
docker tag guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-vaapi-${OS_NAME}${OS_VERSION} guaclive/ffmpeg:$OS_NAME-ffmpeg-vaapi-$OS_VERSION-$FFMPEG_VERSION
docker tag guaclive/ffmpeg:ffmpeg${FFMPEG_VERSION}-vaapi-${OS_NAME}${OS_VERSION} guaclive/ffmpeg:$OS_NAME-ffmpeg-vaapi-latest
}
main() {
if [[ $# == 0 ]]; then
echo "Options available: default, default_native, rpi, cuda, vaapi"
exit 0
else
if [[ $1 == "default" ]]; then
build_default
elif [[ $1 == "default_native" ]]; then
build_default_native
elif [[ $1 == "rpi" ]]; then
build_rpi
elif [[ $1 == "cuda" ]]; then
build_cuda
elif [[ $1 == "vaapi" ]]; then
build_vaapi
fi
fi
}
main $@
exit 0