-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·151 lines (134 loc) · 3.47 KB
/
install.sh
File metadata and controls
executable file
·151 lines (134 loc) · 3.47 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
### Checking for prerequisites ###
#check if running as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
#check for docker
if ! command -v docker &> /dev/null
then
echo "Docker is not installed on this host. Please install and run this script again."
exit 1
fi
#check for docker-compose and install if not currently
if command -v docker-compose &> /dev/null
then
echo "docker-compose is installed install will continue"
else
read -p "docker-compose not detected as installed. Would you like to install it now? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[yY]$ ]]
then
curl -Ls "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
fi
fi
### Checking commandline strings ###
if [[ $* == *--[sS][sS][lL]* ]]
then
echo "Installing in HTTPS mode"
SSL="yes"
else
echo "installing in HTTP mode"
SSL="no"
fi
mkdir -p ./nginx ./gitlab
if [ "$SSL" == "yes" ]
then
#Make folder for SSL certs which will be mounted at /tmp on the container
mkdir ./nginx/ssl
#Read in the NGINX SSL config file
#certs will need to be placed in the ./nginx/ssl/ folder before the container is started
echo "server {
listen 443 SSL;
ssl_certificate /tmp/nginx.crt;
ssl_certificate_key /tmp/nginx.key;
location / {
proxy_pass http://gitlabsvr/;
}
}"> ./nginx/nginx.conf
#read in the SSL config for the docker-compose file. Basically the same execpt it binds to 443 as well and mounts the SSL volume
echo "version: '3'
services:
nginx:
image: nginx:latest
container_name: nginx
restart: always
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
- ./nginx/ssl/:/tmp/
environment:
- GITLAB_SERVER=gitlabsvr:80
ports:
- 80:80
- 443:443
networks:
- glnetwork
links:
- gitlabsvr
depends_on:
- gitlabsvr
gitlabsvr:
image: 'gitlab/gitlab-ee:latest'
restart: always
container_name: gitlab
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://localhost'
volumes:
- './gitlab/config:/etc/gitlab'
- './gitlab/logs:/var/log/gitlab'
- './gitlab/data:/var/opt/gitlab'
networks:
- glnetwork
networks:
glnetwork:
driver: bridge">docker-compose.yml
echo "Add your cert and key to ./nginx/ssl/nginx.crt and ./nginx/ssl/nginx.key"
elif [ $SSL == "no" ]
then
# Read in the HTTP NGINX config file.
echo "server {
listen 80;
location / {
proxy_pass http://gitlabsvr/;
}
}"> ./nginx/nginx.conf
# Read in the HTTP docker-compose file
echo "version: '3'
services:
nginx:
image: nginx:latest
container_name: nginx
restart: always
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
environment:
- GITLAB_SERVER=gitlabsvr:80
ports:
- 80:80
networks:
- glnetwork
links:
- gitlabsvr
depends_on:
- gitlabsvr
gitlabsvr:
image: 'gitlab/gitlab-ee:latest'
restart: always
container_name: gitlab
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://localhost'
volumes:
- './gitlab/config:/etc/gitlab'
- './gitlab/logs:/var/log/gitlab'
- './gitlab/data:/var/opt/gitlab'
networks:
- glnetwork
networks:
glnetwork:
driver: bridge">docker-compose.yml
fi
docker-compose up -d