-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-cli.sh
executable file
·54 lines (50 loc) · 1.12 KB
/
docker-cli.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
#!/bin/bash
# set -x
ORG="deye"
NAME="space-elk-web-plugin"
IMAGE="$ORG/$NAME"
CONTAINER="${ORG}_${NAME}"
function logs {
docker logs --timestamps --follow "$CONTAINER"
}
while (( "$#" )); do
case "$1" in
"build")
docker build \
--rm=true \
--tag="$IMAGE" .
;;
"up")
docker run \
--detach \
--name="$CONTAINER" \
--volume=$(pwd)/src:/project/src:rw \
--volume=$(pwd)/dist:/project/dist:rw \
--workdir=/project/src \
"$IMAGE" \
sh -c "npm run dev"
;;
"login")
docker exec -it $(docker ps | grep "$CONTAINER" | awk '{print $1}') bash
;;
"exec")
shift
docker exec -it $(docker ps --all | grep "$CONTAINER" | awk '{print $1}') $1
;;
"down")
docker rm --force "$CONTAINER"
;;
"logs")
logs
;;
"clean-all")
docker rm -fv $(docker ps -qa -f status=exited -f status=restarting -f status=created)
docker rmi $(docker images -qf dangling=true)
;;
*)
echo "You have failed to specify what to do correctly."
exit 1
;;
esac
shift
done