-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathBuild.sh
executable file
·128 lines (119 loc) · 4.58 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
#!/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() {
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 \
--build-arg BUILD_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 ALSA_VERSION=$ALSA_VERSION \
--build-arg FFMPEG_VERSION=$FFMPEG_VERSION \
--platform linux/amd64 \
-f Dockerfile.alpine \
-t datarhei/base:$OS_NAME-ffmpeg-$OS_VERSION-$FFMPEG_VERSION .
docker tag datarhei/base:$OS_NAME-ffmpeg-$OS_VERSION-$FFMPEG_VERSION datarhei/base:$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 \
--build-arg BUILD_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 FFMPEG_VERSION=$FFMPEG_VERSION \
--build-arg RPI_VERSION=$RPI_VERSION \
--build-arg ALSA_VERSION=$ALSA_VERSION \
--platform linux/arm64 \
-f Dockerfile.alpine.rpi \
-t datarhei/base:$OS_NAME-ffmpeg-rpi-$OS_VERSION-$FFMPEG_VERSION .
docker tag datarhei/base:$OS_NAME-ffmpeg-rpi-$OS_VERSION-$FFMPEG_VERSION datarhei/base:$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 datarhei/base:$OS_NAME-ffmpeg-cuda-$OS_VERSION-$FFMPEG_VERSION-$CUDA_VERSION .
docker tag datarhei/base:$OS_NAME-ffmpeg-cuda-$OS_VERSION-$FFMPEG_VERSION-$CUDA_VERSION datarhei/base:$OS_NAME-ffmpeg-cuda-latest
}
function build_vaapi() {
source_env ./Build.ubuntu.env
source_env ./Build.ubuntu.vaapi.env
docker buildx build \
--load \
--build-arg BUILD_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 FFMPEG_VERSION=$FFMPEG_VERSION \
--platform linux/amd64 \
-f Dockerfile.ubuntu.vaapi \
-t datarhei/base:$OS_NAME-ffmpeg-vaapi-$OS_VERSION-$FFMPEG_VERSION .
docker tag datarhei/base:$OS_NAME-ffmpeg-vaapi-$OS_VERSION-$FFMPEG_VERSION datarhei/base:$OS_NAME-ffmpeg-vaapi-latest
}
main() {
if [[ $# == 0 ]]; then
echo "Options available: default, rpi, cuda, vaapi"
exit 0
else
if [[ $1 == "default" ]]; then
build_default
elif [[ $1 == "rpi" ]]; then
build_rpi
elif [[ $1 == "cuda" ]]; then
build_cuda
elif [[ $1 == "vaapi" ]]; then
build_vaapi
fi
fi
}
main $@
exit 0