forked from jarun/bcal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-docker
executable file
·42 lines (34 loc) · 890 Bytes
/
build-docker
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
#!/bin/bash
set -xe
if [[ $# -ne 2 ]]; then
echo "Usage: $0 <OS_TYPE> <OS_VERSION>"
exit 1
fi
os_type="$1"
os_version="$2"
docker_args="-e OS_TYPE=$os_type -e OS_VERSION=$os_version -v $(pwd):/build:rw --rm=true"
case $os_type in
centos|fedora)
# check for correct package manager
if [[ $os_type == "fedora" ]]; then
YUM=dnf
else
YUM=yum
fi
# set up the docker image with a baseline
cat >Dockerfile <<EOF
FROM $os_type:$os_version
RUN mkdir /build
VOLUME /build
RUN $YUM -y install rpm-build libquadmath-devel gcc git make
EOF
sudo docker build -t bcal .
# do the build
sudo docker run $docker_args bcal /bin/bash -c "cd /build && ./redhat/build-rpm"
;;
*)
echo "$OS_TYPE $OS_VERSION not supported!"
exit 1
;;
esac
# vim: et:ai:ts=4:sw=4