Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output server logs and handle SIGTERM #68

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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