From f3c01bfb429197656cacbdd02b3291e3e4019eae Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Fri, 2 Aug 2019 00:01:35 +0100 Subject: [PATCH] Move static assets out of mounted data dirs --- Dockerfile | 1 + build.sh | 8 ++++++++ conf/chaperone.d/start.conf | 7 +++++++ start.sh | 21 +++++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 conf/chaperone.d/start.conf create mode 100755 start.sh diff --git a/Dockerfile b/Dockerfile index 703a791..17f6250 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ RUN go build -o smtpd smtpd.go # Stage 2: build the final container FROM registry.git.autistici.org/ai3/docker/apache2-base:master +COPY start.sh /start.sh COPY build.sh /tmp/build.sh COPY conf/ /etc/ COPY --from=build /go/src/smtpd /usr/bin/smtpd diff --git a/build.sh b/build.sh index 43574ea..f3ebbbd 100755 --- a/build.sh +++ b/build.sh @@ -35,6 +35,14 @@ a2enconf -q serve-cgi-bin # Create mountpoint dirs. mkdir -p /var/lib/lurker +# Lurker installs some package files in mountpoint directories, +# so the original files would disappear "below" the mount. To +# prevent this, we copy the files to a well-known location +# beforehand, and set up links at run-time. +mkdir -p /var/lib/lurker-www +mv /etc/lurker/ui /var/lib/lurker-www/ui +mv /var/lib/lurker/www/index.html /var/lib/lurker-www/index.html + # Clear the existing default config # (this will be mounted externally). rm -fr /etc/lurker/* diff --git a/conf/chaperone.d/start.conf b/conf/chaperone.d/start.conf new file mode 100644 index 0000000..22550ab --- /dev/null +++ b/conf/chaperone.d/start.conf @@ -0,0 +1,7 @@ +lurker_setup.service: { + type: oneshot, + stdout: inherit, + service_groups: INIT, + process_timeout: 60, + command: "/start.sh", +} diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..8a01ede --- /dev/null +++ b/start.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +www_dir=/var/lib/lurker/www +static_dir=/var/lib/lurker-www + +echo "Fixing symlinks..." >&2 + +if [ ! -e ${www_dir}/imgs ]; then + ln -sf /usr/share/lurker/www/imgs ${www_dir}/imgs +fi +if [ ! -e ${www_dir}/index.html ]; then + ln -sf ${static_dir}/index.html ${www_dir}/index.html +fi +if [ ! -e ${www_dir}/ui ]; then + ln -sf ${static_dir}/ui ${www_dir}/ui +fi +if [ ! -e ${www_dir}/lurker.docroot ]; then + touch ${www_dir}/lurker.docroot +fi + +exit 0 -- GitLab