diff options
author | nachoparker <nacho@ownyourbits.com> | 2019-05-11 21:13:19 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2019-05-13 06:31:38 +0300 |
commit | 3b36dd37527076a56c9812c1cfb0950093ce1d19 (patch) | |
tree | cc8f337d5f74a1db033d3a324038c42fc301b6d7 /docker/debian-ncp | |
parent | d9384817c2a14f0889d30bebb89e40a6cb78217c (diff) |
build: refactor docker builds
Signed-off-by: nachoparker <nacho@ownyourbits.com>
Diffstat (limited to 'docker/debian-ncp')
-rw-r--r-- | docker/debian-ncp/Dockerfile | 16 | ||||
-rwxr-xr-x | docker/debian-ncp/run-parts.sh | 52 |
2 files changed, 65 insertions, 3 deletions
diff --git a/docker/debian-ncp/Dockerfile b/docker/debian-ncp/Dockerfile index 0345eb45..3d4e68bf 100644 --- a/docker/debian-ncp/Dockerfile +++ b/docker/debian-ncp/Dockerfile @@ -1,9 +1,19 @@ -FROM debian:stretch-slim +ARG arch=armhf +ARG arch_qemu=arm +FROM debian:stretch-slim AS qemu -MAINTAINER Ignacio Núñez Hernanz <nacho@ownyourbits.com> +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends qemu-user-static + +FROM ${arch}/debian:stretch-slim + +ARG arch_qemu + +LABEL maintainer="Ignacio Núñez Hernanz <nacho@ownyourbits.com>" CMD /bin/bash +COPY --from=qemu /usr/bin/qemu-${arch_qemu}-static /usr/bin/ + RUN mkdir -p /etc/services-available.d /etc/services-enabled.d -COPY docker-common/debian-ncp/run-parts.sh / +COPY docker/debian-ncp/run-parts.sh / diff --git a/docker/debian-ncp/run-parts.sh b/docker/debian-ncp/run-parts.sh new file mode 100755 index 00000000..6ae2c4e0 --- /dev/null +++ b/docker/debian-ncp/run-parts.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +cleanup() +{ + for file in $( ls -1rv /etc/services-enabled.d ); do + /etc/services-enabled.d/"$file" stop "$1" + done + exit +} + +trap cleanup SIGTERM + +# if an empty volume is mounted to /data, pre-populate it +[[ $( ls -1A /data | wc -l ) -eq 0 ]] && { echo "Initializing empty volume.."; cp -raT /data-ro /data; } + +# wrapper to simulate update-rc.d +cat > /usr/local/sbin/update-rc.d <<'EOF' +#!/bin/bash +FILE=/etc/services-available.d/???"$1" + +test -f $FILE || { + echo "$1 doesn't exist" + exit 0 +} + +[[ "$2" == "enable" ]] && { + ln -sf $FILE /etc/services-enabled.d/$( basename $FILE ) + echo "enabled $1" + exit 0 +} + +[[ "$2" == "disable" ]] && { + rm -f /etc/services-enabled.d/$( basename $FILE ) + echo "disabled $1" + exit 0 +} +EOF +chmod +x /usr/local/sbin/update-rc.d + +# Iterate only over 000* entries which might setup environment +for file in $( ls -1v /etc/services-enabled.d | grep ^000.* ); do + /etc/services-enabled.d/"$file" start "$1" +done + +# Iterate over remaining entries +for file in $( ls -1v /etc/services-enabled.d | grep -v ^000.* ); do + /etc/services-enabled.d/"$file" start "$1" +done + +# wait for trap from 'docker stop' +echo "Init done" +while true; do sleep 0.5; done |