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

Last change on this file since 10503 was 10395, checked in by wiese, 8 months ago

add: build dockerfile for centos7

  • Property svn:executable set to *
File size: 2.3 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 buildBookworm () {
37 echo "Build BNC $bncvers for debian 12 (bookworm) ..."
38 [ -f "bncnew" ] && rm bncnew
39 docker build -t bookworm/bnc:v$bncvers -f docker/Dockerfile.bookworm .
40 getBncFromImage "bookworm/bnc:v$bncvers"
41 target=$(realpath "bnc-$bncvers-debian12")
42 mv bncnew $target
43 echo "$target created"
44}
45
46function buildLeap () {
47 echo "Build BNC $bncvers for opensuse (leap) ..."
48 [ -f "bncnew" ] && rm bncnew
49 docker build -t leap/bnc:v$bncvers -f docker/Dockerfile.leap .
50 getBncFromImage "leap/bnc:v$bncvers"
51 target=$(realpath "bnc-$bncvers-leap")
52 mv bncnew $target
53 echo "$target created"
54}
55
56function buildUbi8 () {
57 echo "Build BNC $bncvers for redhat/ubi8 ..."
58 [ -f "bncnew" ] && rm bncnew
59 docker build -t ubi8.6/bnc:v$bncvers -f docker/Dockerfile.ubi8 .
60 getBncFromImage "ubi8.6/bnc:v$bncvers"
61 target=$(realpath "bnc-$bncvers-el8.6")
62 mv bncnew $target
63 echo "$target created"
64}
65
66case $1 in
67 "bullseye")
68 buildBullseye;
69 ;;
70 "bookworm")
71 buildBookworm;
72 ;;
73 "leap")
74 buildLeap;
75 ;;
76 "ubi")
77 buildUbi8;
78 ;;
79 "all")
80 buildBookworm;
81 buildLeap;
82 buildUbi8;
83 ;;
84 *)
85 echo "Usage:"
86 echo " $0 { bullseye | leap | ubi | all }"
87 echo
88 exit 1;
89 ;;
90esac
91
Note: See TracBrowser for help on using the repository browser.