-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-run-build.sh
executable file
·82 lines (76 loc) · 2.88 KB
/
docker-run-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
#!/bin/sh
# build in local docker container, uses same cmds as github workblow
# run latest images by default
TAG="${2:-latest}"
# add post build cmds
CLEANUP="
test -e venv/pyvenv.cfg && rm -rf venv
test -e build/spy && rm -rf build
"
UBUNTU="
python3 -m venv venv && . venv/bin/activate
pip3 install --upgrade pip wheel setuptools
pip3 install -r requirements.txt
pip3 install pyinstaller sysv-ipc geoip2 flask
./build.sh && mkdir -p ./build-ubuntu && mv -f *.tar.gz *.sha512sum ./build-ubuntu
"
DEBIAN="
export DEBIAN_FRONTEND=noninteractive
apt-get update -y
apt-get install -y wget python3 python3-venv python3-pip
python3 -m venv venv && . venv/bin/activate
pip3 install --upgrade pip wheel setuptools
pip3 install --force -r requirements.txt
pip3 install --force pyinstaller sysv-ipc geoip2 flask
./build.sh && mkdir -p ./build-debian && mv -f *.tar.gz *.sha512sum ./build-debian
./build.sh _WITH_BUNDLE && mkdir -p ./build-debian && mv -f *.tar.gz *.sha512sum ./build-debian
"
_CENTOS_EOL="
yum install -y gcc python3-devel python3-pip python3-virtualenv
python3 -m venv venv && . venv/bin/activate
pip3 install --upgrade pip wheel setuptools
pip3 install -r requirements.txt
pip3 install pyinstaller sysv-ipc geoip2
./build.sh && mkdir -p ./build-centos && mv -f *.tar.gz *.sha512sum ./build-centos
"
ALPINE="
apk add python3 python3-dev py3-pip py3-virtualenv gcc musl-dev
python3 -m venv venv && . venv/bin/activate
pip3 install --upgrade pip wheel setuptools
pip3 install -r requirements.txt
pip3 install pyinstaller sysv-ipc geoip2 flask
./build.sh && mkdir -p ./build-alpine && mv -f *.tar.gz *.sha512sum ./build-alpine
./build.sh _WITH_BUNDLE && mkdir -p ./build-alpine && mv -f *.tar.gz *.sha512sum ./build-alpine
"
RHEL="
dnf install -y gcc python3-devel python3-pip
dnf install -y epel-release
python3 -m venv venv && . venv/bin/activate
pip3 install --upgrade pip wheel setuptools
pip3 install -r requirements.txt
pip3 install pyinstaller sysv-ipc geoip2
./build.sh && mkdir ./build-$1 && mv -f *.tar.gz *.sha512sum ./build-$1
"
func_docker_run() {
image=$1
shift
if [ -n "$DEBUG" ] && [ "$DEBUG" -eq 1 ]; then
docker run -it --workdir /build -v "$PWD:/build" "$image" sh
else
docker run --rm --workdir /build -v "$PWD:/build" "$image" sh -c "
$*
$CLEANUP
"
fi
}
# shellcheck disable=SC2046
case $1 in
ubuntu) func_docker_run "ubuntu:$TAG" "$UBUNTU" ;;
debian) func_docker_run "debian:$TAG" "$DEBIAN" ;;
#centos7) func_docker_run centos:7 "$_CENTOS_EOL" ;;
centos-stream) func_docker_run "quay.io/centos/centos:$TAG" "$RHEL" ;;
alma) func_docker_run "almalinux:$TAG" "$RHEL" ;;
rocky) func_docker_run "rockylinux:$TAG" "$RHEL" ;;
alpine) func_docker_run "alpine:$TAG" "$ALPINE" ;;
*) printf "USAGE: %s <%s>\n" "$0" "$(grep -Pow ' \K[a-z-]+\)' "$0" | sed 's/)//g' | sed ':a;N;$!ba;s/\n/|/g')" ;;
esac