forked from AlexsLemonade/refinebio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_command.sh
More file actions
executable file
·68 lines (56 loc) · 1.59 KB
/
run_command.sh
File metadata and controls
executable file
·68 lines (56 loc) · 1.59 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/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="$(perl -e 'use File::Basename;
use Cwd "abs_path";
print dirname(abs_path(@ARGV[0]));' -- "$0")"
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"
chmod -R a+rwX "$volume_directory"
fi
. ./scripts/common.sh
HOST_IP=$(get_ip_address)
DB_HOST_IP=$(get_docker_db_ip_address)
chmod -R a+rwX "$volume_directory"
./scripts/prepare_image.sh -i "$image" -s workers
image_name=ccdlstaging/dr_"$image"
docker run \
--add-host=database:"$DB_HOST_IP" \
--add-host=nomad:"$HOST_IP" \
--env-file workers/environments/local \
--env AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY \
--volume "$volume_directory":/home/user/data_store \
--link drdb:postgres \
-it "$image_name" bash -c "$@"