-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack_deploy_local.sh
45 lines (33 loc) · 1.33 KB
/
stack_deploy_local.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
#!/bin/sh
# Deploy Jenkins DevOps container locally
# Not in swarm mode
set -e
# variables
IMAGE_TAG="2018.04.19"
GIT_EMAIL="[email protected]"
GIT_USER="jenkins"
# Make local bind-mounted directories
mkdir -p ~/jenkins_home/.ssh/ || echo "Directory already exists..."
mkdir -p ~/jenkins_home/backup/ || echo "Directory already exists..."
# ensure latest image is pulled...
# docker pull nir750/jenkins-devops:${IMAGE_TAG}
# create Jenkins container
docker-compose \
-f docker-compose-local.yml \
-p devopstack up \
--force-recreate -d
echo "Letting services start-up (sleep for 60 seconds)..."
sleep 60
# Configure Jenkins container
JENKINS_CONTAINER=$(docker ps | grep jenkops | awk '{print $1}')
docker exec -it ${JENKINS_CONTAINER} \
bash -c "mkdir /var/jenkins_home/backup/" || echo "Directory already exists..."
docker exec -it ${JENKINS_CONTAINER} \
bash -c "git config --global user.email ${GIT_EMAIL} && git config --global user.name ${GIT_USER}"
docker exec -it -u root ${JENKINS_CONTAINER} \
bash -c "ls -al /var/run/docker.sock && chgrp jenkins /var/run/docker.sock"
docker logs $(docker ps | grep jenkops | awk '{print $1}')
echo "Script completed..."
echo "Jenkins available at: http://localhost:8083"
ADMIN_PASSWORD=$(cat ~/jenkins_home/secrets/initialAdminPassword)
echo "Initial Admin Password: ${ADMIN_PASSWORD}"