mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 13:43:36 +08:00
2fbafd077c
When developing using docker, in order to support symlinks in the `plugins/` directory, this reads the symlinks' values and mounts them to the dev docker container.
103 lines
2.6 KiB
Bash
Executable File
103 lines
2.6 KiB
Bash
Executable File
#!/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"
|
|
PLUGINS_DIR="$SOURCE_DIR/plugins"
|
|
|
|
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}"
|
|
|
|
mount_plugin_symlinks=""
|
|
for symlink in $(find $PLUGINS_DIR -type l); do
|
|
# This deliberately does not use the `-f` option to canonicalize the value
|
|
# because 1) the BSD `readlink` does not support the option, and 2) a
|
|
# relative link would not work inside the container anyway.
|
|
symlink_value=$(readlink $symlink)
|
|
mount_plugin_symlinks+=" -v ${symlink_value}:${symlink_value}:delegated"
|
|
done
|
|
|
|
# 1080 mailcatcher
|
|
# 3000 puma... if you must (but unicorn is preferred)
|
|
# 9292 unicorn
|
|
# 9405 prometheus exporter
|
|
|
|
docker pull discourse/discourse_dev:release
|
|
docker run -d \
|
|
-p 1080:1080 \
|
|
-p 3000:3000 \
|
|
-p 9292:9292 \
|
|
-p 9405:9405 \
|
|
-v "$DATA_DIR:/shared/postgres_data:delegated" \
|
|
-v "$SOURCE_DIR:/src:delegated" \
|
|
$mount_plugin_symlinks \
|
|
$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
|