-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
run_command.sh
executable file
·69 lines (57 loc) · 1.43 KB
/
run_command.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
63
64
65
66
67
68
69
#!/bin/sh
# Script for executing Django management commands within a Docker container.
# Exit on failure
set -e
while getopts "i:" opt; do
case $opt in
i)
IMAGE="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
if [ -z "$IMAGE" ]; then
IMAGE="smasher"
else
shift
shift
fi
# This script should always run as if it were being called from
# the directory it lives in.
script_directory="$(
cd "$(dirname "$0")" || exit
pwd
)"
cd "$script_directory" || exit
# However in order to give Docker access to all the code we have to
# move up a level
cd ..
# Ensure that postgres is running
if ! [ "$(docker ps --filter name=drdb -q)" ]; then
echo "You must start Postgres first with:" >&2
echo "./scripts/run_postgres.sh" >&2
exit 1
fi
volume_directory="$script_directory/volume"
if [ ! -d "$volume_directory" ]; then
mkdir "$volume_directory"
fi
chmod -R a+rwX "$volume_directory"
. ./scripts/common.sh
DB_HOST_IP=$(get_docker_db_ip_address)
./scripts/prepare_image.sh -i "$IMAGE" -s workers
docker run \
--add-host=database:"$DB_HOST_IP" \
--env AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY \
--env-file workers/environments/local \
--interactive \
--link drdb:postgres \
--platform linux/amd64 \
--tty \
--volume "$volume_directory":/home/user/data_store \
"$DOCKERHUB_REPO/dr_$IMAGE" \
bash -c "$@"