File: build.sh

package info (click to toggle)
svnkit 1.10.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 18,332 kB
  • sloc: java: 234,840; sh: 312; xml: 273; makefile: 26; python: 17; perl: 8
file content (83 lines) | stat: -rwxr-xr-x 2,067 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh

usage() {
    echo -e "Usage:"
    echo -e "build.sh [options] [command [command arguments]]"
    echo -e ""
    echo -e "Arguments:"
    echo -e "\t-h --help\tprint this message and exit"
}

DIRECTORY=$(printf "$PWD")
IMAGE_NAME=$(basename "$DIRECTORY")

JAVA_PACKAGE="openjdk-8-jdk-headless"
MAVEN_VERSION="3.6.1"
COMMAND=""
USER_NAME="docker"
DOCKER_HOME="/home/$USER_NAME"
HOST_HOME="$HOME"

while [ "$1" != "" ]; do
    PARAM=`echo $1`
    case ${PARAM} in
        -h | --help)
            usage
            exit
            ;;
        --image-name)
            IMAGE_NAME=`echo $2`
            shift
            ;;
        --java)
            JAVA_PACKAGE=`echo $2`
            shift
            ;;
        -C | --directory)
            DIRECTORY=`echo $2`
            shift
            ;;
        *)
            break
            ;;
    esac
    shift
done

IMAGE_TAG=$(printf "%s_maven-%s" "$JAVA_PACKAGE" "$MAVEN_VERSION")
DOCKER_ARGS="--rm"
if [ -t 1 ] ; then
    DOCKER_ARGS="--interactive --tty --rm"
fi

USER_UID=$(id -u)
USER_GID=$(id -g)

echo "Host home: $HOST_HOME"
echo "Host project directory: $DIRECTORY"
echo "Image: $IMAGE_NAME:$IMAGE_TAG"
echo "Container home: $DOCKER_HOME"
echo "Container args: $DOCKER_ARGS"
echo "Container user: $USER_UID:$USER_GID"
echo "Command: $*"

docker build ${DOCKER_BUILD_OPTS} -t "$IMAGE_NAME:$IMAGE_TAG" \
    --build-arg USER_UID="$USER_UID" \
    --build-arg USER_GID="$USER_GID" \
    --build-arg USER_NAME="$USER_NAME" \
    --build-arg GROUP_NAME="$USER_NAME" \
    --build-arg PROJECT_HOME="$DOCKER_HOME/project" \
    --build-arg USER_HOME="$DOCKER_HOME" \
    --build-arg JAVA_PACKAGE="$JAVA_PACKAGE" \
    "$DIRECTORY"

docker run  ${DOCKER_RUN_OPTS} \
    -v "$DIRECTORY:$DOCKER_HOME/project" \
    -v "$HOST_HOME/.m2:$DOCKER_HOME/.m2" \
    -v "$HOST_HOME/.gradle:$DOCKER_HOME/.gradle" \
    -v "$HOST_HOME/.mavenrc:$DOCKER_HOME/.mavenrc" \
    -v "$HOST_HOME/.gnupg:$DOCKER_HOME/.gnupg" \
    -v "$HOST_HOME/ca:$DOCKER_HOME/ca" \
    ${DOCKER_ARGS} \
    "$IMAGE_NAME:$IMAGE_TAG" \
    $*