source: ntrip/trunk/BNC/docker/build.sh@ 9759

Last change on this file since 9759 was 9759, checked in by wiese, 2 months ago

ADD: dockerfiles

  • Property svn:executable set to *
File size: 1.9 KB
Line 
1#!/bin/bash
2
3# Build BNC from sources for multiple operating systems
4# On redhat/centos install "dnf install podman-docker"
5# Wiese, 2022
6
7set -e
8cd "$(dirname $0)/.."
9
10bncvers=$(grep "#define BNCVERSION \"" src/bncversion.h | cut -d " " -f3 | tr -d \")
11if [ -z "$bncvers" ]; then
12 echo "ERROR: could not find bncvers"; exit 1
13fi
14
15# Run image, copy the compiled executable "bncnew" from the container
16# and then remove the container.
17function getBncFromImage () {
18 local image="$1"
19 local imgID=$(docker images --format "{{.ID}}" $image)
20 local con=$(docker create $imgID)
21 docker cp $con:/tmp/BNC/bnc bncnew
22 docker rm $con
23 [ -s "bncnew" ] || { echo "executable \"bncnew\" does not exist"; exit 1; }
24}
25
26function buildBullseye () {
27 echo "Build BNC $bncvers for debian 11 (bullseye) ..."
28 [ -f "bncnew" ] && rm bncnew
29 docker build -t bullseye/bnc:v$bncvers -f docker/Dockerfile.bullseye .
30 getBncFromImage "bullseye/bnc:v$bncvers"
31 target=$(realpath "bnc-$bncvers-debian11")
32 mv bncnew $target
33 echo "$target created"
34}
35
36function buildLeap () {
37 echo "Build BNC $bncvers for opensuse (leap) ..."
38 [ -f "bncnew" ] && rm bncnew
39 docker build -t leap/bnc:v$bncvers -f docker/Dockerfile.leap .
40 getBncFromImage "leap/bnc:v$bncvers"
41 target=$(realpath "bnc-$bncvers-leap")
42 mv bncnew $target
43 echo "$target created"
44}
45
46function buildUbi8 () {
47 echo "Build BNC $bncvers for redhat/ubi8 ..."
48 [ -f "bncnew" ] && rm bncnew
49 docker build -t ubi8.6/bnc:v$bncvers -f docker/Dockerfile.ubi8 .
50 getBncFromImage "ubi8.6/bnc:v$bncvers"
51 target=$(realpath "bnc-$bncvers-el8.6")
52 mv bncnew $target
53 echo "$target created"
54}
55
56case $1 in
57 "bullseye")
58 buildBullseye;
59 ;;
60 "leap")
61 buildLeap;
62 ;;
63 "all")
64 buildBullseye;
65 buildLeap;
66 ;;
67 *)
68 echo "Usage:"
69 echo " $0 { bullseye | leap | ubi8 | all }"
70 echo
71 exit 1;
72 ;;
73esac
74
Note: See TracBrowser for help on using the repository browser.