Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject Vue APP_URL at page load time #2153

Merged
merged 2 commits into from
May 8, 2024
Merged
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
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ RUN if [ "$DEVELOPMENT_BUILD" = '1' ]; then \
cp /cdash/.env.dev /cdash/.env; \
fi

RUN npm run prod --stats-children

# Make sure the build args are set in the ENV for reference in docker-entrypoint.sh
ENV DEVELOPMENT_BUILD=$DEVELOPMENT_BUILD
ENV BASE_IMAGE=$BASE_IMAGE
Expand Down
4 changes: 2 additions & 2 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ php artisan key:check || exit 1
# If the "start-website" argument was provided, start the web server
if [ "$1" = "start-website" ] ; then
if [ "$DEVELOPMENT_BUILD" = "1" ]; then
bash /cdash/install.sh --dev
bash /cdash/install.sh --dev --initial-docker-install
else
bash /cdash/install.sh
bash /cdash/install.sh --initial-docker-install
fi

echo "Starting Apache..."
Expand Down
43 changes: 29 additions & 14 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
#!/bin/bash

if [[ "$1" == "--dev" ]]; then
DEVELOPMENT=true
else
DEVELOPMENT=false
fi
DEVELOPMENT=false
INITIAL_DOCKER_INSTALL=false

for ARG in "$@"; do
shift
if [[ "$ARG" == "--dev" ]]; then
DEVELOPMENT=true
fi
if [[ "$ARG" == "--initial-docker-install" ]]; then
INITIAL_DOCKER_INSTALL=true
fi
done

echo "=================================================================================";
if $DEVELOPMENT; then
echo "Beginning development CDash installation..."
else
echo "Configuring production CDash installation..."
echo "Beginning production CDash installation..."
fi

error_handler() {
Expand Down Expand Up @@ -38,13 +45,17 @@ pushd "/cdash" > /dev/null
echo "Enabling maintenance mode..."
php artisan down --render="maintenance" --refresh=5

echo "Updating vendor dependencies..."
if $DEVELOPMENT; then
npm install
composer install
if $INITIAL_DOCKER_INSTALL; then
echo "Skipping vendor installation..."
else
npm install --omit=dev
composer install --no-dev --optimize-autoloader
echo "Updating vendor dependencies..."
if $DEVELOPMENT; then
npm install
composer install
else
npm install --omit=dev
composer install --no-dev --optimize-autoloader
fi
fi

echo "Creating storage directories..."
Expand All @@ -58,8 +69,12 @@ php artisan route:cache
php artisan view:cache
php artisan lighthouse:cache

echo "Building the website..."
npm run prod --stats-children
if $INITIAL_DOCKER_INSTALL; then
echo "Skipping website build..."
else
echo "Building the website..."
npm run prod --stats-children
fi

echo "Bringing CDash back online..."
php artisan up
Expand Down
4 changes: 2 additions & 2 deletions resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ const app = Vue.createApp({
components: cdash_components,
});

app.config.globalProperties.$baseURL = process.env.MIX_APP_URL;
app.config.globalProperties.$baseURL = $('#app').attr('data-app-url');

axios.defaults.baseURL = process.env.MIX_APP_URL;
axios.defaults.baseURL = app.config.globalProperties.$baseURL;
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
const token = document.head.querySelector('meta[name="csrf-token"]');
if (token) {
Expand Down
7 changes: 4 additions & 3 deletions resources/views/cdash.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@
<div ng-if="cdash.requirelogin == 1" ng-include="'login'"></div>
<div ng-if="cdash.requirelogin != 1" id="app">
@else
<div id="app">
<div
id="app"
data-app-url="{{ url('/') }}"
>
@endif
@section('header')
@include('components.header')
Expand All @@ -82,8 +85,6 @@
@section('footer')
@include('components.footer')
@show

@yield('post_content_script')
</div>
</body>
</html>