-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
64 lines (62 loc) · 2.23 KB
/
bootstrap.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
#!/bin/bash
if [ -n "${1}" ]; then jenkins_user="${1}"; fi
if [ -n "${2}" ]; then jenkins_password="${2}"; fi
echo ########################
echo "${1}"
echo "${2}"
echo "${jenkins_user}"
echo "${jenkins_password}"
echo ########################
### Install Docker Engine on Ubuntu ###
# https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
# - Update the apt package index and install packages to allow apt to use a repository over HTTPS:
sudo apt-get update -y
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
# - Add Docker’s official GPG key:
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# - Use the following command to set up the stable repository.
sudo echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# - Update the apt package index, and install the latest version of Docker Engine and containerd
sudo apt-get update -y
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo systemctl enable docker
### Install Jenkins Docker Container ###
# https://www.jenkins.io/doc/book/installing/docker/
sudo docker network create jenkins
sudo docker run \
--restart unless-stopped \
--name jenkins-docker \
--detach \
--privileged \
--network jenkins \
--network-alias docker \
--env DOCKER_TLS_CERTDIR=/certs \
--volume jenkins-docker-certs:/certs/client \
--volume jenkins-data:/var/jenkins_home \
--publish 2376:2376 \
--restart unless-stopped \
docker:dind \
--storage-driver overlay2
sudo docker run \
--restart unless-stopped \
--name jenkins-jcasc \
--detach \
--network jenkins \
--env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client \
--env DOCKER_TLS_VERIFY=1 \
--publish 8080:8080 \
--publish 50000:50000 \
--volume jenkins-data:/var/jenkins_home \
--volume jenkins-docker-certs:/certs/client:ro \
--env JENKINS_ADMIN_ID="${jenkins_user}" \
--env JENKINS_ADMIN_PASSWORD="${jenkins_password}" \
tkleiber/jenkins:jcasc