mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Add support for relative root url without the need to recompile
This commit is contained in:
@@ -19,7 +19,9 @@ x-op-app: &app
|
||||
environment:
|
||||
- "RAILS_CACHE_STORE=memcache"
|
||||
- "OPENPROJECT_CACHE__MEMCACHE__SERVER=cache:11211"
|
||||
- "OPENPROJECT_RAILS__RELATIVE__URL__ROOT=${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}"
|
||||
- "DATABASE_URL=postgres://postgres:p4ssw0rd@db/openproject"
|
||||
- "USE_PUMA=true"
|
||||
# set to true to enable the email receiving feature. See ./docker/cron for more options
|
||||
- "IMAP_ENABLED=false"
|
||||
volumes:
|
||||
@@ -55,6 +57,7 @@ services:
|
||||
- "8080:80"
|
||||
environment:
|
||||
- APP_HOST=web
|
||||
- "OPENPROJECT_RAILS__RELATIVE__URL__ROOT=${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}"
|
||||
depends_on:
|
||||
- web
|
||||
networks:
|
||||
|
||||
@@ -41,11 +41,25 @@ if [ "$(id -u)" = '0' ]; then
|
||||
mkdir -p $APP_DATA_PATH/{files,git,svn}
|
||||
chown -R $APP_USER:$APP_USER $APP_DATA_PATH /etc/apache2/sites-enabled/
|
||||
|
||||
# Clean up any dangling PID file
|
||||
rm -f $APP_PATH/tmp/pids/*
|
||||
|
||||
# Clean up a dangling PID file of apache
|
||||
if [ -e "$APACHE_PIDFILE" ]; then
|
||||
rm -f $APACHE_PIDFILE || true
|
||||
fi
|
||||
|
||||
# Fix assets path if relative URL is used
|
||||
relative_url_root_without_trailing_slash="$(echo $OPENPROJECT_RAILS__RELATIVE__URL__ROOT | sed 's:/*$::')"
|
||||
if [ "$relative_url_root_without_trailing_slash" != "" ]; then
|
||||
for file in $(egrep -lR "/assets/" "$APP_PATH/public"); do
|
||||
# only the font paths in the CSSs need updating
|
||||
sed -i "s|/assets/|${relative_url_root_without_trailing_slash}/assets/|g" $file
|
||||
# the .gz is the one served by puma, so rebuild it
|
||||
gzip --force --keep $file
|
||||
done
|
||||
fi
|
||||
|
||||
if [ ! -z "$ATTACHMENTS_STORAGE_PATH" ]; then
|
||||
mkdir -p "$ATTACHMENTS_STORAGE_PATH"
|
||||
chown -R "$APP_USER:$APP_USER" "$ATTACHMENTS_STORAGE_PATH"
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
ProxyRequests off
|
||||
ProxyPreserveHost On
|
||||
|
||||
<Location />
|
||||
ProxyPass http://<%= ENV.fetch("APP_HOST", "127.0.0.1") %>:8080/ retry=0
|
||||
ProxyPassReverse http://<%= ENV.fetch("APP_HOST", "127.0.0.1") %>:8080/
|
||||
<Location <%= ENV.fetch("OPENPROJECT_RAILS__RELATIVE__URL__ROOT", "").chomp("/") %>/>
|
||||
ProxyPass http://<%= ENV.fetch("APP_HOST", "127.0.0.1") %>:8080<%= ENV.fetch("OPENPROJECT_RAILS__RELATIVE__URL__ROOT", "").chomp("/") %>/ retry=0
|
||||
ProxyPassReverse http://<%= ENV.fetch("APP_HOST", "127.0.0.1") %>:8080<%= ENV.fetch("OPENPROJECT_RAILS__RELATIVE__URL__ROOT", "").chomp("/") %>/
|
||||
</Location>
|
||||
</VirtualHost>
|
||||
|
||||
@@ -110,13 +110,5 @@ fi
|
||||
echo "-----> Database setup finished."
|
||||
echo " On first installation, the default admin credentials are login: admin, password: admin"
|
||||
|
||||
if [ -n "$OPENPROJECT_RAILS__RELATIVE__URL__ROOT" ]; then
|
||||
echo
|
||||
echo "-----> Precompiling assets since RAILS_RELATIVE_URL_ROOT is set. This may take a minute."
|
||||
RAILS_RELATIVE_URL_ROOT=$OPENPROJECT_RAILS__RELATIVE__URL__ROOT bash /app/docker/precompile-assets.sh
|
||||
echo "-----> Asset precompilation finished."
|
||||
echo
|
||||
fi
|
||||
|
||||
echo "-----> Launching supervisord..."
|
||||
exec /usr/bin/supervisord -c $APP_PATH/docker/supervisord.conf -e ${SUPERVISORD_LOG_LEVEL}
|
||||
|
||||
Reference in New Issue
Block a user