From adbe79d6bdfbf3708befc3aae8ab6506c09faee3 Mon Sep 17 00:00:00 2001 From: Guiorgy Date: Wed, 28 Aug 2024 20:03:16 +0400 Subject: [PATCH] use a named pipe and --log-file to output logs --- .gitattributes | 5 +++++ Dockerfile | 3 ++- docker-entrypoint.sh | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .gitattributes create mode 100644 docker-entrypoint.sh diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..951b138 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# Force Unix style line endings for files that will be copied into the Docker image +*.sh text eol=lf + +# Auto detect text files and perform LF normalization on the rest +* text=auto diff --git a/Dockerfile b/Dockerfile index 5207be4..a9fe268 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM alpine:3.20.2 -CMD [ "/usr/bin/svnserve", "--daemon", "--foreground", "--root", "/var/opt/svn" ] +COPY docker-entrypoint.sh / +CMD [ "/docker-entrypoint.sh" ] EXPOSE 3690 HEALTHCHECK CMD netstat -ln | grep 3690 || exit 1 VOLUME [ "/var/opt/svn" ] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..5cc5f26 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +# create a pipe for svnserve logs +rm -f /var/svn/svnlogs +mkfifo /var/svn/svnlogs + +# run the SVN service in the background +/usr/bin/svnserve --daemon --root /var/opt/svn --log-file=/var/svn/svnlogs & +# remember the PID of the SVN server +SVNSERVE_PID=$! + +# redirect svnserve logs to stdout +cat /var/svn/svnlogs + +# stop the SVN server running in the background +kill --signal SIGTERM $SVNSERVE_PID