Skip to content

Commit 6d1e8c0

Browse files
committed
publish
0 parents  commit 6d1e8c0

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/*
2+
!/entrypoint.sh

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM alpine:3.7
2+
RUN apk add --no-cache subversion
3+
COPY . /usr/local/bin
4+
WORKDIR /workspace
5+
VOLUME [ "/workspace" ]
6+
ENTRYPOINT [ "entrypoint.sh" ]
7+
CMD [ "svn" ]

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
Just subversion client executable from container where `svn` command can not be installed.
3+
4+
## Usage
5+
As `svn` script
6+
```bash
7+
#!/bin/bash
8+
exec docker run --rm \
9+
-e UID="$(id -u)" -e GID="$(id -g)" -e SVN_USERNAME -e SVN_PASSWORD \
10+
-v "$(pwd):/workspace" -v "$HOME/.subversion:/home/user/.subversion" \
11+
profiprog/svn svn $@
12+
```
13+
or just as an alias
14+
```bash
15+
alias svn='docker run --rm -e UID="$(id -u)" -e GID="$(id -g)" -e SVN_USERNAME -e SVN_PASSWORD -v "$(pwd):/workspace" -v "$HOME/.subversion:/home/user/.subversion" profiprog/svn svn'
16+
```
17+
18+
Whe `SVN_USERNAME` and `SVN_PASSWORD` environment variables are deffined subversion client automaticaly use them.

entrypoint.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
#echo "GID=$GID ($(id -g)) UID=$UID ($(id -u))"
4+
if ! [ -z "$GID" -a -z "$UID" ] && [ "$(id -g)" -ne "$GID" -o "$(id -u)" -ne "$UID" ]; then
5+
GROUP="$(getent group "$GID" | awk -F: '{print$1}')"
6+
if [ -z "$GROUP" ]; then addgroup -g "$GID" user || exit; fi
7+
adduser -h /home/user -s /bin/sh -G "${GROUP:-user}" -S -D -u "$UID" user
8+
exec su user -- "$0" "$@"
9+
fi
10+
11+
_contains() {
12+
local arg="$1"; shift
13+
while [ $# -gt 0 ]; do [ "$1" == "$arg" ] && return 0; shift; done
14+
return 1
15+
}
16+
17+
_is_svn_command() { _contains "$1" "add" "auth" "blame" "praise" "annotate" "ann" \
18+
"cat" "changelist" "cl" "checkout" "co" "cleanup" "commit" "ci" "copy" "cp" \
19+
"delete" "del" "remove" "rm" "diff" "di" "export" "help" "?" "h" "import" "info" \
20+
"list" "ls" "lock" "log" "merge" "mergeinfo" "mkdir" "move" "mv" "rename" "ren" \
21+
"patch" "propdel" "pdel" "pd" "propedit" "pedit" "pe" "propget" "pget" "pg" \
22+
"proplist" "plist" "pl" "propset" "pset" "ps" "relocate" "resolve" "resolved" \
23+
"revert" "status" "stat" "st" "switch" "sw" "unlock" "update" "up" "upgrade"; }
24+
25+
26+
if [ "${1:0:1}" == "-" ] || _is_svn_command "$1"; then set -- svn "$@"; fi
27+
28+
if [ "$1" == "svn" ] && ! [ -z "$SVN_USERNAME" -a -z "$SVN_PASSWORD" ]; then
29+
shift
30+
set -- --no-auth-cache "$@"
31+
[ "$SVN_USERNAME" ] && ! _contains --username "$@" && set -- --username "$SVN_USERNAME" "$@"
32+
[ "$SVN_PASSWORD" ] && ! _contains --password "$@" && set -- --password "$SVN_PASSWORD" "$@"
33+
fi
34+
35+
exec "$@"

svn

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
exec docker run --rm \
3+
-e UID="$(id -u)" -e GID="$(id -g)" -e SVN_USERNAME -e SVN_PASSWORD \
4+
-v "$(pwd):/workspace" -v "$HOME/.subversion:/home/user/.subversion" \
5+
profiprog/svn svn "$@"

0 commit comments

Comments
 (0)