forked from nielsbasjes/yauaa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-docker.sh
executable file
·116 lines (95 loc) · 3.81 KB
/
start-docker.sh
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
#
# Yet Another UserAgent Analyzer
# Copyright (C) 2013-2019 Niels Basjes
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
OS=centos7
PROJECTNAME=yauaa
USER=$(id -un)
CONTAINER_NAME=${PROJECTNAME}-${OS}-${USER}-$$
DOCKER_BUILD="docker build"
if [ -n "${INSIDE_DOCKER+x}" ];
then
echo "Nothing to do: You are already INSIDE the docker environment"
exit 1;
fi
if [[ "$(docker images -q ${PROJECTNAME}-${OS} 2> /dev/null)" == "" ]]; then
DOCKER_BUILD="docker build"
cat << "Welcome-message"
_____ _ _ _ _ _
/ ___| | | | | (_) (_) | |
\ `--. ___| |_| |_ _ _ __ __ _ _ _ _ __ ___ _ ____ ___ _ __ ___ _ __ _ __ ___ ___ _ __ | |_
`--. \/ _ \ __| __| | '_ \ / _` | | | | | '_ \ / _ \ '_ \ \ / / | '__/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __|
/\__/ / __/ |_| |_| | | | | (_| | | |_| | |_) | | __/ | | \ V /| | | | (_) | | | | | | | | | __/ | | | |_
\____/ \___|\__|\__|_|_| |_|\__, | \__,_| .__/ \___|_| |_|\_/ |_|_| \___/|_| |_|_| |_| |_|\___|_| |_|\__|
__/ | | |
|___/ |_|
For building Yet Another UserAgent Analyzer
This will take a few minutes...
Welcome-message
else
DOCKER_BUILD="docker build -q"
echo "Loading Yauaa development environment"
fi
${DOCKER_BUILD} -t ${PROJECTNAME}-${OS} docker/${OS}
if [ "$(uname -s)" == "Linux" ]; then
USER_NAME=${SUDO_USER:=${USER}}
USER_ID=$(id -u "${USER_NAME}")
GROUP_ID=$(id -g "${USER_NAME}")
else # boot2docker uid and gid
USER_NAME=${USER}
USER_ID=1000
GROUP_ID=50
fi
EXTRA_DOCKER_STEPS=""
if [ -f "${HOME}/.gitconfig" ];
then
cp "${HOME}/.gitconfig" ___git_config_for_docker
EXTRA_DOCKER_STEPS="ADD ___git_config_for_docker /home/${USER}/.gitconfig"
fi
cat - > ___UserSpecificDockerfile << UserSpecificDocker
FROM ${PROJECTNAME}-${OS}
${EXTRA_DOCKER_STEPS}
RUN bash /scripts/configure-for-user.sh "${USER_NAME}" "${USER_ID}" "${GROUP_ID}" "$(grep -F vboxsf /etc/group)"
UserSpecificDocker
${DOCKER_BUILD} -t "${PROJECTNAME}-${OS}-${USER_NAME}" -f ___UserSpecificDockerfile .
buildStatus=$?
if [ ${buildStatus} -ne 0 ];
then
exit ${buildStatus}
fi
rm -f ___git_config_for_docker ___UserSpecificDockerfile
# Do NOT Map the real ~/.m2 directory !!!
[ -d "${PWD}/docker/_m2" ] || mkdir "${PWD}/docker/_m2"
[ -d "${PWD}/docker/_gnupg" ] || mkdir "${PWD}/docker/_gnupg"
MOUNTGPGDIR="${PWD}/docker/_gnupg"
if [[ "${1}" == "RELEASE" ]];
then
cp "${HOME}"/.m2/*.xml "${PWD}/docker/_m2"
MOUNTGPGDIR="${HOME}/.gnupg"
echo "Setting up for release process"
fi
docker run --rm=true -t -i \
-u "${USER_NAME}" \
-v "${PWD}:/home/${USER_NAME}/${PROJECTNAME}" \
-v "${PWD}/docker/_m2:/home/${USER_NAME}/.m2" \
-v "${MOUNTGPGDIR}:/home/${USER_NAME}/.gnupg" \
-w "/home/${USER}/${PROJECTNAME}" \
-p 4000:4000 \
-p 35729:35729 \
--name "${CONTAINER_NAME}" \
"${PROJECTNAME}-${OS}-${USER_NAME}" \
bash
exit 0