Skip to content

Commit

Permalink
Fixed https (cachethq#383) and app startup (cachethq#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pulsebright committed Apr 26, 2021
1 parent 264cd7f commit 1ec7451
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
32 changes: 31 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CMD ["/sbin/entrypoint.sh"]
ARG cachet_ver
ARG archive_url

ENV cachet_ver ${cachet_ver:-v2.3.18}
ENV cachet_ver ${cachet_ver:-2.4}
ENV archive_url ${archive_url:-https://github.com/cachethq/Cachet/archive/${cachet_ver}.tar.gz}

ENV COMPOSER_VERSION 1.9.0
Expand Down Expand Up @@ -104,3 +104,33 @@ USER root
RUN chmod g+rwx /var/run/nginx.pid && \
chmod -R g+rw /var/www /usr/share/nginx/cache /var/cache/nginx /var/lib/nginx/ /etc/php7/php-fpm.d storage
USER 1001

RUN set -e; \
# HOTFIX 1: force root URL and schema
# We locate the boot() method in AppServiceProvider.php
#ls /var/www/html/app/Foundation/Providers/AppServiceProvider.php \
line=$(grep -n 'public function boot(Dispatcher $dispatcher)$' /var/www/html/app/Providers/AppServiceProvider.php | tail -n1 | cut -f1 -d:); \
\
# We insert the code 2 lines after because there is a "{" on a separate line
insertAtLine=$((line+2)); \
\
# We insert the hotfix
sed -i "$insertAtLine i \\ \
if (getenv('APP_URL')) { \n \
if (strpos(getenv('APP_URL'), 'https') === 0) { \n \
\\\URL::forceScheme('https'); \n \
} \n \
\\\URL::forceRootUrl(getenv('APP_URL')); \n \
} \n \
" /var/www/html/app/Providers/AppServiceProvider.php; \
\
# We forward the APP_URL environment variable to FPM
echo '[www]' > /etc/php7/php-fpm.d/app-url-fix.conf; \
echo 'env[APP_URL] = $APP_URL' >> /etc/php7/php-fpm.d/app-url-fix.conf; \
\
# HOTFIX 2: fix login redirection to dashboard
# Normally it redirects to the last URL, but since Laravel is not able to detect URLs right, we force a redirection to dashboard
sed -i "s/Redirect::intended(cachet_route('dashboard'));/cachet_redirect('dashboard');/g" \
/var/www/html/app/Http/Controllers/AuthController.php; \
sed -i "s/Redirect::intended('dashboard');/cachet_redirect('dashboard');/g" \
/var/www/html/app/Http/Controllers/AuthController.php
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ initialize_system() {

init_db() {
echo "Initializing Cachet database ..."
php artisan cachet:install --no-interaction
php artisan app:install --no-interaction
check_configured
}

Expand Down

0 comments on commit 1ec7451

Please sign in to comment.