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..f37240e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,15 @@ FROM alpine:3.20.2 -CMD [ "/usr/bin/svnserve", "--daemon", "--foreground", "--root", "/var/opt/svn" ] EXPOSE 3690 + HEALTHCHECK CMD netstat -ln | grep 3690 || exit 1 + VOLUME [ "/var/opt/svn" ] WORKDIR /var/opt/svn RUN apk add --no-cache \ subversion==1.14.3-r2 \ wget==1.24.5-r0 + +COPY docker-entrypoint.sh / +ENTRYPOINT docker-entrypoint.sh diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..d08713f --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,20 @@ +#!/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 --foreground --root /var/opt/svn --log-file=/var/svn/svnlogs & +# remember the PID of the SVN server +SVNSERVE_PID=$! + +# redirect SIGTERM to the SVN service +trap "kill -s SIGTERM $SVNSERVE_PID" SIGTERM + +# redirect svnserve logs to stdout +while read -r line < /var/svn/svnlogs; do + printf '%s\n' "$line" +done