forked from greenpeace/planet4-docker-compose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean.sh
executable file
·49 lines (42 loc) · 1001 Bytes
/
clean.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
#!/usr/bin/env bash
set -ea
PROJECT=${PROJECT:-$(basename "${PWD}" | sed 's/[.-]//g')}
COMPOSE_FILES=(
"docker-compose.yml"
"docker-compose.ci.yml"
"docker-compose.stateless.yml"
)
for f in "${COMPOSE_FILES[@]}"
do
# Remove containers, local images (db) and the shared volumes
docker-compose -p "${PROJECT}" -f "$f" down --rmi local -v || true
done
if [ -d "persistence" ]
then
echo
echo "Deleting persistence directory (requires sudo to remove DB files)..."
echo " \$ sudo rm -fr $(pwd)/persistence"
echo
read -p "Are you sure? [y/N] " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo
sudo rm -fr persistence
fi
fi
CONTENT_PATH=${CONTENT_PATH:-defaultcontent}
if [ -d "${CONTENT_PATH}" ]
then
echo
echo "Deleting ${CONTENT_PATH} directory ..."
read -p "Are you sure? [y/N] " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo
set -x >/dev/null
rm -fr "${CONTENT_PATH}"
set +x >/dev/null
fi
fi
# Remoove generated Dockerfile
rm -f db/Dockerfile