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

Minor improvements to build process and startup scripts #1023

Closed
wants to merge 3 commits into from
Closed
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ The interface allows for easy adaptation of the UI by modifying certain elements
- `UI_SHOW_SHARE_BUTTON`
- `UI_SHOW_CHAT_HISTORY_BUTTON`

Any custom images assigned to variables `UI_LOGO`, `UI_CHAT_LOGO` or `UI_FAVICON` should be added to the [public](https://github.com/microsoft/sample-app-aoai-chatGPT/tree/main/frontend/public) folder before building the project. The Vite build process will automatically copy theses files to the [static](https://github.com/microsoft/sample-app-aoai-chatGPT/tree/main/static) folder on each build of the frontend. The corresponding environment variables should then be set using a relative path such as `static/<my image filename>` to ensure that the frontend code can find them.

Feel free to fork this repository and make your own modifications to the UX or backend logic. You can modify the source (`frontend/src`). For example, you may want to change aspects of the chat display, or expose some of the settings in `app.py` in the UI for users to try out different behaviors. After your code changes, you will need to rebuild the front-end via `start.sh` or `start.cmd`.

### Scalability
Expand Down
14 changes: 14 additions & 0 deletions start.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
@echo off
setlocal
REM Sample app startup script

REM Process CLI options
set CMD=%~1
if "%CMD%" == "" (
echo Building the application. To skip this step in the future, use the `--skip-build` option.
goto build
) else if "%CMD%" == "--skip-build" (
echo Skipping build...
goto run
)

:build
set NODE_OPTIONS=--max_old_space_size=8192

echo.
Expand Down Expand Up @@ -30,6 +43,7 @@ if "%errorlevel%" neq "0" (
exit /B %errorlevel%
)

:run
echo.
echo Starting backend
echo.
Expand Down
96 changes: 69 additions & 27 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,76 @@
#!/bin/bash
#!/bin/bash -e

# script usage info
function usage() {
cat <<USAGE

Usage: $0 [-s|--skip-build]

Options:
-s, --skip-build: Optional.
USAGE
exit 1
}

function build() {
echo "Building the application. To skip this step in the future, use the `--skip-build` option."
echo ""
echo "Restoring frontend npm packages"
echo ""
cd frontend
npm install
if [ $? -ne 0 ]; then
echo "Failed to restore frontend npm packages"
exit $?
fi

echo ""
echo "Building frontend"
echo ""
npm run build
if [ $? -ne 0 ]; then
echo "Failed to build frontend"
exit $?
fi
cd ..

echo ""
echo "Restoring backend python packages"
. ./scripts/loadenv.sh
}

function run() {
echo ""
echo "Starting backend"
echo ""
./.venv/bin/python -m quart run --port=50505 --host=127.0.0.1 --reload
if [ $? -ne 0 ]; then
echo "Failed to start backend"
exit $?
fi
}

SKIP_BUILD=0
while [ "$1" != "" ]; do
case $1 in
-s | --skip-build)
SKIP_BUILD=1
;;
*)
usage
exit 1
;;
esac
shift
done

export NODE_OPTIONS=--max_old_space_size=8192

echo ""
echo "Restoring frontend npm packages"
echo ""
cd frontend
npm install
if [ $? -ne 0 ]; then
echo "Failed to restore frontend npm packages"
exit $?
if [[ $SKIP_BUILD == 0 ]]; then
build
fi

echo ""
echo "Building frontend"
echo ""
npm run build
if [ $? -ne 0 ]; then
echo "Failed to build frontend"
exit $?
fi
run


cd ..
. ./scripts/loadenv.sh

echo ""
echo "Starting backend"
echo ""
./.venv/bin/python -m quart run --port=50505 --host=127.0.0.1 --reload
if [ $? -ne 0 ]; then
echo "Failed to start backend"
exit $?
fi
Loading