This repository was archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuildDocker.sh
More file actions
52 lines (43 loc) · 1.31 KB
/
Copy pathbuildDocker.sh
File metadata and controls
52 lines (43 loc) · 1.31 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
#!/bin/bash
########################################################
## Shell Script to Build Docker Image by FOSSTechNix.com
########################################################
DATE=`date +%Y.%m.%d.%H.%M`
username=<git username>
password=<password>
DIR=/home/sivasaisagar/helloworld
FILE=/home/sivasaisagar/output
container_name=helloworld
if [ -d "$DIR" ];
then
printf '%s\n' "helloworld dir ($DIR)"
rm -rf "$DIR"
else
echo "now no helloworld a dir"
fi
echo "cloning a helloworld dir"
sudo git clone https://<username>:<password>@github.com/USivaSaiSagar/helloworld.git
result=$( sudo docker images -q helloworld )
if [[ -n "$result" ]]; then
echo "image exists"
sudo docker rmi -f helloworld
else
echo "No such image"
fi
echo "change the dir"
echo "delete output file"
cd /home/sivasaisagar/helloworld/
echo "build the docker image"
sudo docker build -t helloworld/sivasai:$DATE . >> /home/sivasaisagar/output
echo "built docker images and proceeding to delete existing container"
result=$( docker ps -q -f name=helloworld )
if [[ $? -eq 0 ]]; then
echo "Container exists"
sudo docker container rm -f helloworld
echo "Deleted the existing docker container"
else
echo "No such container"
fi
echo "Deploying the updated container"
sudo docker run -itd -p 3000:3000 --name helloworld $OUTPUT
echo "Deploying the container"