owncast/build/admin/bundleAdmin.sh
Gabe Kangas 1dbd550134
Bundle and serve admin (#317)
* WIP with admin bundling

* Current state of the admin is bundled

* Update admin bundler to work with binary bundling

* Log detail about the admin interface. Closes #312

* Move bundle script to the build dir

* Update to current version of admin

* Commit updated API documentation

Co-authored-by: Owncast <owncast@owncast.online>
2020-11-06 15:12:35 -08:00

40 lines
923 B
Bash
Executable file

#!/usr/bin/env bash
# shellcheck disable=SC2059
set -o errexit
set -o nounset
set -o pipefail
INSTALL_TEMP_DIRECTORY="$(mktemp -d)"
PROJECT_SOURCE_DIR=$(pwd)
cd $INSTALL_TEMP_DIRECTORY
shutdown () {
rm -rf "$PROJECT_SOURCE_DIR/admin"
rm -rf "$INSTALL_TEMP_DIRECTORY"
}
trap shutdown INT TERM ABRT EXIT
echo "Cloning owncast admin into $INSTALL_TEMP_DIRECTORY..."
git clone --depth 1 https://github.com/owncast/owncast-admin 2> /dev/null
cd owncast-admin
echo "Installing npm modules for the owncast admin..."
npm --silent install 2> /dev/null
echo "Building owncast admin..."
rm -rf .next
(node_modules/.bin/next build && node_modules/.bin/next export) | grep info
echo "Copying admin to project directory..."
ADMIN_BUILD_DIR=$(pwd)
cd $PROJECT_SOURCE_DIR
mkdir -p admin 2> /dev/null
cd admin
cp -R ${ADMIN_BUILD_DIR}/out/* .
echo "Bundling admin into owncast codebase..."
~/go/bin/pkger
shutdown
echo "Done."