forked from discourse/discourse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot_dev
executable file
·74 lines (63 loc) · 1.86 KB
/
boot_dev
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
70
71
72
73
74
#!/bin/bash
set -e
SCRIPTPATH=$(cd "$(dirname "$0")" > /dev/null; pwd -P)
SOURCE_DIR=$(cd "$SCRIPTPATH" > /dev/null; cd ../.. > /dev/null; pwd -P)
DATA_DIR="$SOURCE_DIR/data/postgres"
show_help() {
cat <<EOF
Usage: ${0##*/} [-e VAR=VAL] [--env VAR=VAL] [--env-file filename] [-h] [--init]
-e, --env set environment variables
--env-file pass in a file containing a list of environment variable assignments
--init perform first-time initialization
EOF
}
initialize=""
ENV_ARGS=""
while [ "${#@}" -ne "0" ]; do
case "$1" in
-h | --help)
show_help
exit 0
;;
-i | --init)
initialize="initialize"
;;
-e | --env)
if [ -z "$2" ]; then
show_help
exit 0
else
ENV_ARGS+=" -e $2"
shift
fi
;;
--env-file)
if [ -z "$2" ]; then
show_help
exit 0
else
ENV_ARGS="--env-file=$2"
break
fi
;;
*)
echo "unexpected argument: $1" >& 2
show_help >& 2
exit 1
;;
esac
shift
done
echo "Using source in: ${SOURCE_DIR}"
echo "Using data in: ${DATA_DIR}"
mkdir -p "${DATA_DIR}"
docker run -d -p 1080:1080 -p 3000:3000 -v "$DATA_DIR:/shared/postgres_data:delegated" -v "$SOURCE_DIR:/src:delegated" $ENV_ARGS --hostname=discourse --name=discourse_dev --restart=always discourse/discourse_dev:release /sbin/boot
if [ "${initialize}" = "initialize" ]; then
echo "Installing gems..."
"${SCRIPTPATH}/bundle" install
echo "Migrating database..."
"${SCRIPTPATH}/rake" db:migrate
RAILS_ENV=test "${SCRIPTPATH}/rake" db:migrate
echo "Creating admin user..."
"${SCRIPTPATH}/rake" admin:create
fi