Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ A discourse container config file is created when a discourse app is created. Th

You can edit the config at `/home/dokku/APP_NAME/discourse_standalone.yml`. Don't make any changes to the `volumes` section, but feel free to change anything else.

Warning: The env part is overrided by dokku-discourse plugin. If you want to use custom configuration, and skip this override, please use the following syntaxe :
`dokku discourse:create <app> <hostname to listen> --skip-env-config`

After making change be sure to run `dokku discourse:create <app>` to rebuild and re-deploy the discourse app.

### Upgrade a discourse app
Expand Down
12 changes: 7 additions & 5 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ discourse_create_app() {

[[ -z "$APP_NAME" ]] && dokku_log_fail "Missing app argument"
[[ -z "$HOSTNAME" ]] && HOSTNAME=$(fn-get-input "Hostname for your Discourse?" "$(fn-get-env-config DISCOURSE_HOSTNAME)")
[[ -z "$DEVELOPER_EMAILS" ]] && DEVELOPER_EMAILS=$(fn-get-input "Email address for admin account(s)?" "$(fn-get-env-config DISCOURSE_DEVELOPER_EMAILS)")
[[ -z "$SMTP_ADDRESS" ]] && SMTP_ADDRESS=$(fn-get-input "SMTP server address?" "$(fn-get-env-config DISCOURSE_SMTP_ADDRESS)")
[[ -z "$SMTP_PORT" ]] && SMTP_PORT=$(fn-get-input "SMTP port?" "$(fn-get-env-config DISCOURSE_SMTP_PORT)")
[[ -z "$SMTP_USERNAME" ]] && SMTP_USERNAME=$(fn-get-input "SMTP user name?" "$(fn-get-env-config DISCOURSE_SMTP_USER_NAME)")
[[ -z "$SMTP_PASSWORD" ]] && SMTP_PASSWORD=$(fn-get-input "SMTP password?" "$(fn-get-env-config DISCOURSE_SMTP_PASSWORD)")
if [ "$DEVELOPER_EMAILS" != "--skip-env-config" ]; then
[[ -z "$DEVELOPER_EMAILS" ]] && DEVELOPER_EMAILS=$(fn-get-input "Email address for admin account(s)?" "$(fn-get-env-config DISCOURSE_DEVELOPER_EMAILS)")
[[ -z "$SMTP_ADDRESS" ]] && SMTP_ADDRESS=$(fn-get-input "SMTP server address?" "$(fn-get-env-config DISCOURSE_SMTP_ADDRESS)")
[[ -z "$SMTP_PORT" ]] && SMTP_PORT=$(fn-get-input "SMTP port?" "$(fn-get-env-config DISCOURSE_SMTP_PORT)")
[[ -z "$SMTP_USERNAME" ]] && SMTP_USERNAME=$(fn-get-input "SMTP user name?" "$(fn-get-env-config DISCOURSE_SMTP_USER_NAME)")
[[ -z "$SMTP_PASSWORD" ]] && SMTP_PASSWORD=$(fn-get-input "SMTP password?" "$(fn-get-env-config DISCOURSE_SMTP_PASSWORD)")
fi

local APP_STORAGE_ROOT="$STORAGE_ROOT/$APP_NAME"

Expand Down
29 changes: 16 additions & 13 deletions internal-functions
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,16 @@ fn-update-discourse-container-config() {
SMTP_PORT="$6" \
SMTP_USER_NAME="$7" \
SMTP_PASSWORD="$8"

fn-update-discourse-config-env \
"$APP_NAME" \
"$HOSTNAME" \
"$DEVELOPER_EMAILS" \
"$SMTP_ADDRESS" \
"$SMTP_PORT" \
"$SMTP_USER_NAME" \
"$SMTP_PASSWORD"
if [ "$DEVELOPER_EMAILS" != "--skip-env-config" ]; then
fn-update-discourse-config-env \
"$APP_NAME" \
"$HOSTNAME" \
"$DEVELOPER_EMAILS" \
"$SMTP_ADDRESS" \
"$SMTP_PORT" \
"$SMTP_USER_NAME" \
"$SMTP_PASSWORD"
fi

fn-update-discourse-config-set-volumes "$APP_NAME" "$APP_STORAGE_ROOT"

Expand Down Expand Up @@ -179,10 +180,12 @@ fn-get-env-vars-from-run-args() {
# RUN_ARGS will be a string in form "+ true run --shm-size=512m -d --restart=always -e LANG=en_US.UTF-8 -e RAILS_ENV=production" etc
# We want to extract the env vars from the string and produce a new string in form "ENV=var ENV2=var"
# 1. We use grep to extract the "-e ENV=var" strings
# 2. grep will give us newlines, so we convert those to spaces using tr
# 3. Next we use sed to remove "-e" flags as well as multiple consecutive whitespace chars
# 4. Finally we use sed to trim leading and trailing spaces
echo "$RUN_ARGS" | grep -Po '[[:space:]]-e[[:space:]]*[^[:space:]]+' | tr "\n" "\t" | sed -r "s/\s+\-e\s+|\s+/ /g" | sed -r 's/^\s*|\s*$//g'
# 2. Next we use sed to remove "-e" flags
# 3. Then we use sed to remove leading and trailing single quote if exists (docker env escaping strategy)
# 4. grep will give us newlines, so we convert those to spaces using tr
# 5. Finally we use sed to trim leading and trailing spaces
echo "$RUN_ARGS" | grep -Po '[[:space:]]-e[[:space:]]*[^[:space:]]+' | sed -r "s/\s+\-e\s+//g" | sed -r 's/^\x27|\x27$//g' | tr '\n' ' ' | sed -r 's/^\s*|\s*$//g'

}

fn-configure-app() {
Expand Down