-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathdeploy
executable file
·58 lines (44 loc) · 1.63 KB
/
deploy
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
#!/bin/bash
# All rights reserved, Saeid Bostandoust <[email protected]>.
echo "INFO: Welcome to \"DevOps with Saeid\" class (www.devops-with-saeid.com)."
if [[ $(docker info -f json | jq '.ClientInfo.Plugins | any(.Name == "compose")') == "true" ]]; then
DOCKER_COMPOSE_COMMAND="docker compose"
else
DOCKER_COMPOSE_COMMAND="docker-compose"
which docker-compose &> /dev/null
if [ $? -ne 0 ]; then
echo "ERROR: docker-compose is not installed."
exit 1
fi
fi
mkdir -p certs
SYSTEM_IP_ADDRESSES=($(hostname -I))
if [ -f certs/registry.crt ]; then
echo "INFO: It seems jenkins-stack is already deployed."
exit 0
fi
sed -i"" "s/subjectAltName=.*/subjectAltName=IP:${SYSTEM_IP_ADDRESSES[0]}/g" openssl.conf
openssl req -newkey rsa:2048 -nodes -keyout certs/registry.key \
-x509 -sha256 -days 3650 -subj "/CN=docker-registry" \
-out certs/registry.crt -extensions san -config openssl.conf &> /dev/null
if [ ! -f certs/registry.crt ]; then
echo "ERROR: OpenSSL cannot creates registry certificate."
exit 1
else
echo "INFO: Docker registry certificate created successfully."
fi
export JENKINS_DOCKER_REGISTRY_IP=${SYSTEM_IP_ADDRESSES[0]}
$DOCKER_COMPOSE_COMMAND up -d
echo "INFO: jenkins-stack deployed successfully."
echo "INFO: Deployment preparation may take a while."
cat <<EOL
Jenkins URL: http://${SYSTEM_IP_ADDRESSES[0]}:8080
Gitea URL: http://${SYSTEM_IP_ADDRESSES[0]}:3000
Docker registry URL: https://$JENKINS_DOCKER_REGISTRY_IP
To use the Docker registry add this code to your Docker "daemon.json" file:
{
"insecure-registries": [
"$JENKINS_DOCKER_REGISTRY_IP"
]
}
EOL