-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateByAlpine.sh
93 lines (81 loc) · 2.41 KB
/
CreateByAlpine.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
#!/bin/sh
set -e
#description: Build Docker Container script by lxb1628 <[email protected]>
#
#Some Scripts Copyed by Wind4
#
check_result() {
if [ $1 -ne 0 ]; then
echo "Error: $2" >&2
exit $1
fi
}
if [ "x$(id -u)" != 'x0' ]; then
echo 'Error: This script can only be executed by root'
exit 1
fi
if [ ! -f '/bin/tar' ]; then
echo 'Installing tar ...'
yum -q -y install tar
check_result $? "Can't install tar."
echo 'Install tar succeed.'
fi
if [ ! -f '/usr/bin/wget' ]; then
echo 'Installing wget ...'
yum -q -y install wget
check_result $? "Can't install wget."
echo 'Install wget succeed.'
fi
if [ ! -f '/sbin/service' ]; then
echo 'Installing initscripts ...'
yum -q -y install initscripts
check_result $? "Can't install initscripts."
echo 'Install initscripts succeed.'
fi
# prepare the download URL
GIT_TAG=$(curl -L -s -H 'Accept: application/json' https://github.com/Wind4/vlmcsd/releases/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
TMP_DIR=`mktemp -d`
cd ${TMP_DIR}
echo 'Downloading vlmcsd ...'
curl -sSL https://github.com/Wind4/vlmcsd/releases/download/${GIT_TAG}/binaries.tar.gz -o binaries.tar.gz
check_result $? 'Download vlmcsd failed.'
echo 'Extract vlmcsd ...'
tar -xzvf binaries.tar.gz
Work_DIR=/tmp/docker-kms
mkdir ${Work_DIR}
cp binaries/Linux/intel/musl/vlmcsdmulti-x64-musl ${Work_DIR}/vlmcsd
echo 'Create Docker Image ...'
cd ${Work_DIR}
# create Dockerfile Script
if [ ! -e Dockerfile ]; then
cat >Dockerfile <<-'EOF'
# base image
FROM alpine:latest as builder
# MAINTAINER
MAINTAINER yygfml<[email protected]>
WORKDIR /root
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk update && apk upgrade
RUN apk add --no-cache git make build-base && \
git clone --branch master --single-branch https://github.com/Wind4/vlmcsd.git && \
cd vlmcsd/ && \
make
FROM alpine:latest
WORKDIR /root/
# put vlmcsd into /usr/local/bin
COPY --from=builder /root/vlmcsd/bin/vlmcsd /usr/bin/vlmcsd
EXPOSE 1688/tcp
# execute command to compile vlmcsd
CMD [ "/usr/bin/vlmcsd", "-D", "-d" ]
EOF
fi
# build kms-server:latest container
docker build -t kms-server:latest .
#docker run -d kms-server:latest
docker run -d -p 1688:1688 --restart=always --name kms kms-server
echo 'Cleaning ...'
cd ~
rm -rf ${TMP_DIR}
rm -rf ${Work_DIR}
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
echo 'Installed successfully.'