-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_static.sh
executable file
·48 lines (41 loc) · 1.07 KB
/
build_static.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
#!/bin/bash
#
# Builds a statically linked version of an app
#
# Usage:
#
# ./build_static.sh app arch
APP_NAME=$1
ARCH=$2
usage () {
echo "Usage: $0 <app> <arch>"
}
if [ -z "${APP_NAME}" ]; then
usage
exit 1
fi
if [ "${APP_NAME}" = "-h" ]; then
usage
exit 0
fi
if [ -z "${ARCH}" ]; then
usage
exit 1
fi
# Build the statically linked binary if it doesn't already exist
if [ -d "static/${APP_NAME}" ] && [ ! -d "packages/static/${APP_NAME}" ]; then
# TODO: Only AMD64 supported
if [[ "$(docker images -q static_builder_${APP_NAME}_${ARCH}:latest 2> /dev/null)" == "" ]]; then
docker build -f static/${APP_NAME}/${ARCH}.Dockerfile -t static_builder_${APP_NAME}_${ARCH} .
fi
# Create statically linked version of the program
if [[ "$(docker images -q static_builder_${APP_NAME}_${ARCH}:latest 2> /dev/null)" != "" ]]; then
docker run -it -v $(pwd):/data static_builder_${APP_NAME}_${ARCH}:latest /bin/bash -c "\
cd /data;\
find -type f -name \"*.sh\" -exec chmod +x {} +;\
cd /data/static/${APP_NAME};\
./build.sh;"
else
echo "Docker container build failing!"
fi
fi