Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
init-dbmigration.sh 768 B
#!/bin/bash

# If there are files in /tmp/configmap that are not empty
# (overriden by a ConfigMap) copy them to /discourse/config
if [ -n "$(ls -A /tmp/discourse-configmap)" ]
then
  for f in /tmp/discourse-configmap/*
  do
    if [ -s $f ]
    then
      cp /tmp/discourse-configmap/* /discourse/config/
    fi
  done
fi

# Replace environment variables
# This is mandatory as at the time of doing the migration, discourse needs to know redis IP,
# which is set thanks to discourse.conf file.
echo "--> Overwritting env variables ..."
envsubst < /tmp/discourse-configmap/discourse.conf > /discourse/config/discourse.conf
echo "--> DONE"

# Set environment as production
export RAILS_ENV="production"

# Create or Migrate DB
exec bundle exec rake db:create db:migrate