@@ -5,17 +5,62 @@ function die() {
5
5
exit 1
6
6
}
7
7
8
- if [[ $# -eq 1 ]]; then
9
- image_version=$1
10
- else
11
- image_version=latest
12
- fi
8
+ image_version=latest
9
+ name=" silverdev-${image_version} "
10
+ while [[ $# -gt 0 ]]; do
11
+ key=" $1 "
12
+ case $key in
13
+ -h)
14
+ echo " Usage: run.sh [-i IMAGE_VERSION] [-w WORKING_DIR] [-n NAME]"
15
+ echo " Spawns and runs a container from the Docker image silverpeas/silverdev at a given version."
16
+ echo " In order to build the projects in that container, the working directory of your projects"
17
+ echo " will be mounted in the container. It checks if a Maven settings settings-docker.xml exist"
18
+ echo " in order to use it in the container. Otherwise, it is your settings.xml that will be used."
19
+ echo " The following files or directories will be also used in the container: "
20
+ echo " - The Maven security configuration settings-security.xml"
21
+ echo " - The Git configuration .gitconfig"
22
+ echo " - The ssh configuration directory .ssh"
23
+ echo " - The GPG configuration directory .gnupg"
24
+ echo " "
25
+ echo " with:"
26
+ echo " -i IMAGE_VERSION the version of the Docker image to instantiate. By default latest."
27
+ echo " -g WORKING_DIR the path of your working directory to mount The working directory"
28
+ echo " will be mounted to /home/silveruser/projects. By default nothing to"
29
+ echo " mount."
30
+ echo " -n NAME a name to give to the container. By default silverdev-IMAGE_VERSION."
31
+ exit 0
32
+ ;;
33
+ -i)
34
+ image_version=" $2 "
35
+ shift # past argument
36
+ shift # past value
37
+ ;;
38
+ -w)
39
+ working_dir=" -v " $2 " :/home/silveruser/projects"
40
+ shift # past argument
41
+ shift # past value
42
+ ;;
43
+ -n)
44
+ name=" $2 "
45
+ shift # past argument
46
+ shift # past value
47
+ ;;
48
+ * )
49
+ die " Unknown option: $1 "
50
+ ;;
51
+ esac
52
+ done
13
53
14
54
# run the silverpeas build image by linking the required volumes for signing and deploying built artifacts.
15
- docker run -it -v " $HOME " /.m2/settings.xml:/home/silveruser/.m2/settings.xml \
55
+ if [[ -f " $HOME " /.m2/settings-docker.xml ]]; then
56
+ settings=" $HOME " /.m2/settings-docker.xml
57
+ else
58
+ settings=" $HOME " /.m2/settings.xml
59
+ fi
60
+ docker run -it ${working_dir} -v " ${settings} " :/home/silveruser/.m2/settings.xml \
16
61
-v " $HOME " /.m2/settings-security.xml:/home/silveruser/.m2/settings-security.xml \
17
62
-v " $HOME " /.gitconfig:/home/silveruser/.gitconfig \
18
63
-v " $HOME " /.ssh:/home/silveruser/.ssh \
19
64
-v " $HOME " /.gnupg:/home/silveruser/.gnupg \
20
- --name silverdev- ${image_version } \
65
+ --name ${name } \
21
66
silverpeas/silverdev:${image_version} /bin/bash
0 commit comments