Skip to content

Commit

Permalink
improve installation of core plugins
Browse files Browse the repository at this point in the history
Core plugins are now backed into the image and only manual installed plugins are installed durring startup.
  • Loading branch information
sdorra committed Aug 8, 2017
1 parent d71f061 commit 2f16ed2
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 26 deletions.
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,21 @@ RUN set -x \
# override environment to run redmine with a context path "/redmine"
&& mv ${WORKDIR}/config/environment.ces.rb ${WORKDIR}/config/environment.rb \

# install core plugins to a temporary location
# besure plugin name does not contain a minus or dots,
# because the minus separates the version from the package name
&& mkdir -p /var/tmp/redmine/plugins \
# install core plugins
&& mkdir -p "${WORKDIR}/plugins" \
# install cas plugin
&& mkdir "${WORKDIR}/plugins/redmine_cas" \
&& curl -sL \
https://github.com/cloudogu/redmine_cas/archive/${CAS_PLUGIN_VERSION}.tar.gz \
-o /var/tmp/redmine/plugins/redmine_cas-${CAS_PLUGIN_VERSION}.tar.gz \
| tar xfz - --strip-components=1 -C "${WORKDIR}/plugins/redmine_cas" \
# install redmine_activerecord_session_store to be able to invalidate sessions after cas logout
&& mkdir "${WORKDIR}/plugins/redmine_activerecord_session_store" \
&& curl -sL \
https://github.com/pencil/redmine_activerecord_session_store/archive/v${ACTIVERECORD_SESSION_STORE_PLUGIN_VERSION}.tar.gz \
-o /var/tmp/redmine/plugins/redmine_activerecord_session_store-${ACTIVERECORD_SESSION_STORE_PLUGIN_VERSION}.tar.gz \
| tar xfz - --strip-components=1 -C "${WORKDIR}/plugins/redmine_activerecord_session_store" \

# install plugin gems
&& cd ${WORKDIR}; RAILS_ENV="production" bundle install --without development test \

# cleanup
&& rm -rf /root/* /tmp/* $(gem env gemdir)/cache \
Expand Down
5 changes: 4 additions & 1 deletion dogu.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"Group": "1000"
}, {
"Name": "plugins",
"Path": "/usr/share/webapps/redmine/plugins",
"Path": "/var/tmp/redmine/plugins",
"Owner": "1000",
"Group": "1000"
}, {
Expand All @@ -37,6 +37,9 @@
"Port": 3000
},
"ExposedCommands": [{
"Name": "pre-upgrade",
"Command": "/pre-upgrade.sh"
},{
"Name": "post-upgrade",
"Command": "/post-upgrade.sh"
}]
Expand Down
3 changes: 0 additions & 3 deletions resources/post-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ function exec_rake() {

echo "executing update ${FROM_VERSION} to ${TO_VERSION}"

echo "install dependencies ..."
RAILS_ENV="production" REDMINE_LANG="en" bundle install

echo "migrate database ..."
exec_rake db:migrate

Expand Down
20 changes: 20 additions & 0 deletions resources/pre-upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# older installation of redmine exposed the core plugins to the
# plugin volume, these exposed plugin could be old and must be
# removed.

set -o errexit
set -o nounset
set -o pipefail

PLUGIN_DIRECTORY="${WORKDIR}/plugins"
CORE_PLUGINS="redmine_activerecord_session_store redmine_cas"

for CP in ${CORE_PLUGINS}; do
CP_DIR="${PLUGIN_DIRECTORY}/${CP}"
if [ -d "${CP_DIR}" ]; then
echo "remove old installation of ${CP}"
rm -rf "${CP_DIR}"
fi
done
39 changes: 23 additions & 16 deletions resources/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,41 @@ function exec_rake() {

function install_plugins(){
echo "installing plugins"
for PLUGIN_PACKAGE in $(ls "${PLUGIN_STORE}"); do

PLUGINS=$(ls "${PLUGIN_STORE}")
for PLUGIN_PACKAGE in ${PLUGINS}; do
install_plugin "${PLUGIN_PACKAGE}"
done

echo "install missing gems ..."
RAILS_ENV="${RAILS_ENV}" REDMINE_LANG="${REDMINE_LANG}" bundle install
echo "missing gems ... installed"
# install missing gems only if external plugins are going to install
if [ "x${PLUGINS}" != "x" ]; then
echo "install missing gems ..."
RAILS_ENV="${RAILS_ENV}" REDMINE_LANG="${REDMINE_LANG}" bundle install
echo "missing gems ... installed"
fi

# run migrations always, because core plugins need also a db migration
echo "running plugin migrations..."
exec_rake redmine:plugins:migrate
echo "plugin migrations... done"
}

# installs or upgrades the given plugin
function install_plugin(){
PACKAGE="${1}"
NAME=$(echo "${PACKAGE}" | awk -F'-' '{print $1}')
VERSION=$(echo "${PACKAGE}" | awk -F'-' '{print $NF}' | sed -e 's/\.tar\.gz//g')
DIRECTORY="${PLUGIN_DIRECTORY}/${NAME}"

echo "install plugin ${NAME} in version ${VERSION}"
if [ -d "${DIRECTORY}" ]; then
rm -rf "${DIRECTORY}"
NAME="${1}"
SOURCE="${PLUGIN_STORE}/${NAME}"
TARGET="${PLUGIN_DIRECTORY}/${NAME}"

if [ ! -d "${SOURCE}" ]; then
exit 1
fi

mkdir -p "${DIRECTORY}"
tar xfz "${PLUGIN_STORE}/${PACKAGE}" --strip-components=1 -C "${DIRECTORY}" > /dev/null 2>&1
echo "install plugin ${NAME}"
if [ -d "${TARGET}" ]; then
rm -rf "${TARGET}"
fi

cp -rf "${SOURCE}" "${TARGET}"
}

# adjust redmine database.yml
Expand Down Expand Up @@ -141,8 +149,7 @@ else
sql "DELETE FROM users WHERE login='admin';"
fi


# install core plugins and manual installed plugins
# install manual installed plugins
install_plugins

# Create links
Expand Down

0 comments on commit 2f16ed2

Please sign in to comment.