mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 23:05:48 +08:00
97e2a614c8
add symlink to simplify invoking docker commands `d/rake`
52 lines
1.2 KiB
Bash
Executable File
52 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
SCRIPTPATH=$(cd "$(dirname "$0")"; pwd -P)
|
|
SOURCE_DIR=$(cd "$SCRIPTPATH" && cd ../.. && pwd -P)
|
|
DATA_DIR=$SOURCE_DIR/tmp/postgres
|
|
|
|
show_help() {
|
|
cat <<EOF
|
|
Usage: ${0##*/} [-h] [--init]
|
|
|
|
--init perform first-time initialization
|
|
EOF
|
|
}
|
|
|
|
initialize=""
|
|
|
|
while [ "${#@}" -ne "0" ]; do
|
|
case "$1" in
|
|
-h | --help)
|
|
show_help
|
|
exit 0
|
|
;;
|
|
-i | --init)
|
|
initialize="initialize"
|
|
;;
|
|
*)
|
|
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 -v $SOURCE_DIR:/src --hostname=discourse --name=discourse_dev --restart=always discourse/discourse_dev:latest /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
|