-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.sh
executable file
·52 lines (45 loc) · 899 Bytes
/
start.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
#!/bin/sh
# Instances to start
count=$1
# Provider url
provider_url=$2
# Create .env file
echo "PROVIDER_URL=$provider_url" >.env
# Create docker-compose.yml file content
buildComposeYaml() {
cat <<HEADER
version: '3.0'
services:
HEADER
for ((i = 1; i < $count + 1; i++)); do
if [ $i -eq 1 ]; then
cat <<BLOCK
s$i:
container_name: s$i
image: server-instance
command: npm run start
restart: unless-stopped
env_file:
- .env
BLOCK
else
cat <<BLOCK
s$i:
container_name: s$i
image: server-instance
command: npm run start
restart: unless-stopped
env_file:
- .env
depends_on:
- s$((i - 1))
BLOCK
fi
done
}
# Build image docker from Dockerfile
docker build -t server-instance .
# Add content to the docker-compose file
buildComposeYaml >docker-compose.yml
# Run the compose file
docker-compose up -d