aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2021-03-10 00:29:52 +0100
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2021-03-10 18:46:29 +0100
commit085656ac45c03f4ea68ca2dc1e036c585eeac6b5 (patch)
tree452f87739c5ef8b17a4eae5cde98cd93444cf800
parent44fbe564bb33ef6982770d68138b7ace61c2cfa4 (diff)
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
-rw-r--r--.gitignore1
-rw-r--r--centos8-build/Dockerfile3
-rw-r--r--centos8-obs-latest/Dockerfile3
-rwxr-xr-xcommon/respawn.sh (renamed from osmo-bts-master/respawn.sh)0
-rw-r--r--debian-buster-build/Dockerfile3
-rw-r--r--debian-jessie-build/Dockerfile3
-rw-r--r--debian-sid-build/Dockerfile3
-rw-r--r--debian-stretch-obs-latest/Dockerfile3
-rw-r--r--make/Makefile3
-rw-r--r--osmo-bts-latest/Dockerfile2
-rwxr-xr-xosmo-bts-latest/respawn.sh15
-rw-r--r--osmo-bts-master/Dockerfile2
-rw-r--r--osmo-pcu-latest/Dockerfile2
-rwxr-xr-xosmo-pcu-latest/respawn.sh15
-rw-r--r--osmo-pcu-master/Dockerfile2
-rwxr-xr-xosmo-pcu-master/respawn.sh15
16 files changed, 22 insertions, 53 deletions
diff --git a/.gitignore b/.gitignore
index 0aba0f6..386d3f8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
.release
+.common
/_cache
diff --git a/centos8-build/Dockerfile b/centos8-build/Dockerfile
index 412816c..001c161 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 4b2357b..a9dfc9b 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
index 31a8c06..31a8c06 100755
--- a/osmo-bts-master/respawn.sh
+++ b/common/respawn.sh
diff --git a/debian-buster-build/Dockerfile b/debian-buster-build/Dockerfile
index 119afea..2625e9e 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 60f6ca9..b043762 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 ffa86e2..f4fe990 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 3bef05c..04f831d 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 f149291..d2cacf3 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 202a29c..2b41968 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 2413916..0000000
--- 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 13df628..77c1e51 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 622f933..7f1b3ac 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 2413916..0000000
--- 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 f8e6ded..41cd6d5 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 2413916..0000000
--- 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"