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
This commit is contained in:
Vadim Yanitskiy 2021-03-10 00:29:52 +01:00
parent 44fbe564bb
commit 085656ac45
16 changed files with 22 additions and 53 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.release
.common
/_cache

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -20,8 +20,6 @@ RUN case "$DISTRO" in \
;; \
esac
ADD respawn.sh /usr/local/bin/respawn.sh
WORKDIR /tmp
VOLUME /data

View File

@ -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"

View File

@ -30,8 +30,6 @@ RUN case "$DISTRO" in \
;; \
esac
ADD respawn.sh /usr/local/bin/respawn.sh
WORKDIR /tmp
ARG OSMO_BTS_BRANCH="master"

View File

@ -17,8 +17,6 @@ RUN case "$DISTRO" in \
;; \
esac
ADD respawn.sh /usr/local/bin/respawn.sh
WORKDIR /tmp
VOLUME /data

View File

@ -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"

View File

@ -21,8 +21,6 @@ RUN case "$DISTRO" in \
;; \
esac
ADD respawn.sh /usr/local/bin/respawn.sh
WORKDIR /tmp
ARG OSMO_PCU_BRANCH="master"

View File

@ -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"