-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_support.sh
62 lines (55 loc) · 1.73 KB
/
docker_support.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
#!/bin/bash
# source logger
LOGGER="logger"
. ${LOGGER}.sh
DOCKER_PORT=8000
# Build docker image
function docker_build_image() {
# check if docker-compose.yml exists
if [ -f "docker-compose.yml" ]; then
# Build docker image
e_arrow "Building docker image...."
sudo docker-compose build
e_success "Docker image built"
else
e_error "docker-compose.yml not found"
# Use Dockerfile to build image
e_arrow "Building docker image...."
sudo docker build -t ${DOCKER_IMAGE} .
e_success "Docker image built"
fi
}
# Start docker
function docker_start() {
# if docker is not installed then install it
if ! command -v docker >/dev/null 2>&1; then
e_warning "Docker is not installed. Installing it now..."
sudo apt install -y docker
e_success "Docker is installed."
fi
# if docker-compose is not installed then install it
if ! command -v docker-compose >/dev/null 2>&1; then
e_warning "Docker-compose is not installed. Installing it now..."
sudo apt install -y docker-compose
e_success "Docker-compose is installed."
fi
# Start docker
e_arrow "Starting docker...."
sudo service docker start
e_success "Docker started"
docker_build_image
}
function docker_run(){
if [ -f "docker-compose.yml" ]; then
# Run docker image
e_arrow "Running docker image...."
sudo docker-compose up -d
e_success "Docker image running"
else
e_error "docker-compose.yml not found"
# Run docker image
e_arrow "Running docker image...."
sudo docker run -d -p ${DOCKER_PORT}:${DOCKER_PORT} ${DOCKER_IMAGE}
e_success "Docker image running"
fi
}