From 085656ac45c03f4ea68ca2dc1e036c585eeac6b5 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Wed, 10 Mar 2021 00:29:52 +0100 Subject: [PATCH] Make respawn.sh a common part of *-build/-obs images Maintaining several versions of the same file in different folders is a bad idea, because at some point their content gets out of sync. This is exactly what happened to 'respawn.sh': sleep()ing was only implemented in 'osmo-bts-master/respawn.sh', other versions of this file would simply ignore '$SLEEP_BEFORE_RESPAWN'. The easiest solution would be to have all common files in a single directory, however Docker does not allow to ADD files from outside of the build context. In other words, all files must be in the same directory as the Dockerfile itself. Modify 'make/Makefile' in order to copy the contents of common directory to the current build context ('pre-build' target) and remove it after building ('post-build' target). Change-Id: I3ec86c8610b3b43d39ea8e3da444861d317ced4e --- .gitignore | 1 + centos8-build/Dockerfile | 3 +++ centos8-obs-latest/Dockerfile | 3 +++ {osmo-bts-master => common}/respawn.sh | 0 debian-buster-build/Dockerfile | 3 +++ debian-jessie-build/Dockerfile | 3 +++ debian-sid-build/Dockerfile | 3 +++ debian-stretch-obs-latest/Dockerfile | 3 +++ make/Makefile | 3 +++ osmo-bts-latest/Dockerfile | 2 -- osmo-bts-latest/respawn.sh | 15 --------------- osmo-bts-master/Dockerfile | 2 -- osmo-pcu-latest/Dockerfile | 2 -- osmo-pcu-latest/respawn.sh | 15 --------------- osmo-pcu-master/Dockerfile | 2 -- osmo-pcu-master/respawn.sh | 15 --------------- 16 files changed, 22 insertions(+), 53 deletions(-) rename {osmo-bts-master => common}/respawn.sh (100%) delete mode 100755 osmo-bts-latest/respawn.sh delete mode 100755 osmo-pcu-latest/respawn.sh delete mode 100755 osmo-pcu-master/respawn.sh diff --git a/.gitignore b/.gitignore index 0aba0f6f..386d3f81 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .release +.common /_cache diff --git a/centos8-build/Dockerfile b/centos8-build/Dockerfile index 412816ce..001c1610 100644 --- a/centos8-build/Dockerfile +++ b/centos8-build/Dockerfile @@ -50,5 +50,8 @@ RUN dnf install -y \ sqlite-devel \ telnet +# Make respawn.sh part of this image, so it can be used by other images based on it +COPY .common/respawn.sh /usr/local/bin/respawn.sh + # Invalidate cache once the repository is updated ADD $OSMOCOM_REPO_MIRROR/repositories/network:/osmocom:/latest/CentOS_8/repodata/repomd.xml /tmp/repomd.xml diff --git a/centos8-obs-latest/Dockerfile b/centos8-obs-latest/Dockerfile index 4b2357b3..a9dfc9be 100644 --- a/centos8-obs-latest/Dockerfile +++ b/centos8-obs-latest/Dockerfile @@ -17,5 +17,8 @@ RUN dnf install -y dnf-utils wget && \ RUN dnf install -y \ telnet +# Make respawn.sh part of this image, so it can be used by other images based on it +COPY .common/respawn.sh /usr/local/bin/respawn.sh + # Invalidate cache once the repository is updated ADD $OSMOCOM_REPO_MIRROR/repositories/network:/osmocom:/latest/CentOS_8/repodata/repomd.xml /tmp/repomd.xml diff --git a/osmo-bts-master/respawn.sh b/common/respawn.sh similarity index 100% rename from osmo-bts-master/respawn.sh rename to common/respawn.sh diff --git a/debian-buster-build/Dockerfile b/debian-buster-build/Dockerfile index 119afead..2625e9e2 100644 --- a/debian-buster-build/Dockerfile +++ b/debian-buster-build/Dockerfile @@ -52,3 +52,6 @@ RUN apt-get update && \ stow \ wget && \ apt-get clean + +# Make respawn.sh part of this image, so it can be used by other images based on it +COPY .common/respawn.sh /usr/local/bin/respawn.sh diff --git a/debian-jessie-build/Dockerfile b/debian-jessie-build/Dockerfile index 60f6ca9b..b0437626 100644 --- a/debian-jessie-build/Dockerfile +++ b/debian-jessie-build/Dockerfile @@ -52,3 +52,6 @@ RUN apt-get update && \ stow \ wget && \ apt-get clean + +# Make respawn.sh part of this image, so it can be used by other images based on it +COPY .common/respawn.sh /usr/local/bin/respawn.sh diff --git a/debian-sid-build/Dockerfile b/debian-sid-build/Dockerfile index ffa86e2f..f4fe9907 100644 --- a/debian-sid-build/Dockerfile +++ b/debian-sid-build/Dockerfile @@ -50,3 +50,6 @@ RUN apt-get update && \ sqlite3 \ wget && \ apt-get clean + +# Make respawn.sh part of this image, so it can be used by other images based on it +COPY .common/respawn.sh /usr/local/bin/respawn.sh diff --git a/debian-stretch-obs-latest/Dockerfile b/debian-stretch-obs-latest/Dockerfile index 3bef05cf..04f831d6 100644 --- a/debian-stretch-obs-latest/Dockerfile +++ b/debian-stretch-obs-latest/Dockerfile @@ -18,5 +18,8 @@ RUN apt-key add /tmp/Release.key && \ rm /tmp/Release.key && \ echo "deb " $OSMOCOM_REPO " ./" > /etc/apt/sources.list.d/osmocom-latest.list +# Make respawn.sh part of this image, so it can be used by other images based on it +COPY .common/respawn.sh /usr/local/bin/respawn.sh + # Invalidate cache once the repository is updated ADD $OSMOCOM_REPO/Release /tmp/Release diff --git a/make/Makefile b/make/Makefile index f149291f..d2cacf3a 100644 --- a/make/Makefile +++ b/make/Makefile @@ -55,9 +55,12 @@ SHELL=/bin/bash build: pre-build docker-build post-build pre-build: + rm -rf .common + cp -r $(ROOT_DIR)/common .common post-build: + rm -rf .common post-push: diff --git a/osmo-bts-latest/Dockerfile b/osmo-bts-latest/Dockerfile index 202a29c1..2b419682 100644 --- a/osmo-bts-latest/Dockerfile +++ b/osmo-bts-latest/Dockerfile @@ -20,8 +20,6 @@ RUN case "$DISTRO" in \ ;; \ esac -ADD respawn.sh /usr/local/bin/respawn.sh - WORKDIR /tmp VOLUME /data diff --git a/osmo-bts-latest/respawn.sh b/osmo-bts-latest/respawn.sh deleted file mode 100755 index 24139163..00000000 --- a/osmo-bts-latest/respawn.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -trap "kill 0" EXIT - -i=0 -max_i=500 -while [ $i -lt $max_i ]; do - echo "$i: starting: $*" - $* & - LAST_PID=$! - wait $LAST_PID - echo "$i: stopped pid $LAST_PID with status $?" - i=$(expr $i + 1) -done -echo "exiting after $max_i runs" diff --git a/osmo-bts-master/Dockerfile b/osmo-bts-master/Dockerfile index 13df6280..77c1e512 100644 --- a/osmo-bts-master/Dockerfile +++ b/osmo-bts-master/Dockerfile @@ -30,8 +30,6 @@ RUN case "$DISTRO" in \ ;; \ esac -ADD respawn.sh /usr/local/bin/respawn.sh - WORKDIR /tmp ARG OSMO_BTS_BRANCH="master" diff --git a/osmo-pcu-latest/Dockerfile b/osmo-pcu-latest/Dockerfile index 622f933f..7f1b3acb 100644 --- a/osmo-pcu-latest/Dockerfile +++ b/osmo-pcu-latest/Dockerfile @@ -17,8 +17,6 @@ RUN case "$DISTRO" in \ ;; \ esac -ADD respawn.sh /usr/local/bin/respawn.sh - WORKDIR /tmp VOLUME /data diff --git a/osmo-pcu-latest/respawn.sh b/osmo-pcu-latest/respawn.sh deleted file mode 100755 index 24139163..00000000 --- a/osmo-pcu-latest/respawn.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -trap "kill 0" EXIT - -i=0 -max_i=500 -while [ $i -lt $max_i ]; do - echo "$i: starting: $*" - $* & - LAST_PID=$! - wait $LAST_PID - echo "$i: stopped pid $LAST_PID with status $?" - i=$(expr $i + 1) -done -echo "exiting after $max_i runs" diff --git a/osmo-pcu-master/Dockerfile b/osmo-pcu-master/Dockerfile index f8e6ded5..41cd6d5e 100644 --- a/osmo-pcu-master/Dockerfile +++ b/osmo-pcu-master/Dockerfile @@ -21,8 +21,6 @@ RUN case "$DISTRO" in \ ;; \ esac -ADD respawn.sh /usr/local/bin/respawn.sh - WORKDIR /tmp ARG OSMO_PCU_BRANCH="master" diff --git a/osmo-pcu-master/respawn.sh b/osmo-pcu-master/respawn.sh deleted file mode 100755 index 24139163..00000000 --- a/osmo-pcu-master/respawn.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -trap "kill 0" EXIT - -i=0 -max_i=500 -while [ $i -lt $max_i ]; do - echo "$i: starting: $*" - $* & - LAST_PID=$! - wait $LAST_PID - echo "$i: stopped pid $LAST_PID with status $?" - i=$(expr $i + 1) -done -echo "exiting after $max_i runs"