Adds dist.
This commit is contained in:
71
dist/scripts/build-package.sh
vendored
Executable file
71
dist/scripts/build-package.sh
vendored
Executable file
@@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Build configuration
|
||||
VERSION="${VERSION:-0.1.0}"
|
||||
ARCH="${ARCH:-amd64}"
|
||||
BUILD_DIR="build"
|
||||
SRC_DIR="$BUILD_DIR/src"
|
||||
BINARY_NAME="wild-central"
|
||||
|
||||
# Source paths (relative to dist directory)
|
||||
API_SOURCE=".."
|
||||
WEBAPP_SOURCE="../web"
|
||||
|
||||
echo "Building Wild Central v${VERSION} for ${ARCH}"
|
||||
echo "================================================"
|
||||
|
||||
# Clean and create build directories
|
||||
echo "Preparing build directories..."
|
||||
rm -rf "$SRC_DIR"
|
||||
mkdir -p "$SRC_DIR"
|
||||
mkdir -p "$BUILD_DIR"
|
||||
|
||||
# Copy API source
|
||||
echo ""
|
||||
echo "Copying API source..."
|
||||
rsync -a --exclude='dist/' --exclude='web/' "$API_SOURCE/" "$SRC_DIR/api/"
|
||||
cd "$SRC_DIR/api"
|
||||
|
||||
# Build the daemon
|
||||
echo "Building daemon binary..."
|
||||
if [ "$ARCH" = "arm64" ]; then
|
||||
GOOS=linux GOARCH=arm64 go build -ldflags="-X main.Version=$VERSION" -o "../../$BINARY_NAME" .
|
||||
elif [ "$ARCH" = "amd64" ]; then
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags="-X main.Version=$VERSION" -o "../../$BINARY_NAME" .
|
||||
else
|
||||
echo "Unsupported architecture: $ARCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd - > /dev/null
|
||||
echo "Daemon binary built: $BUILD_DIR/$BINARY_NAME"
|
||||
|
||||
# Copy web app source
|
||||
echo ""
|
||||
echo "Copying web app source..."
|
||||
cp -r "$WEBAPP_SOURCE" "$SRC_DIR/web"
|
||||
cd "$SRC_DIR/web"
|
||||
|
||||
# Remove any local env overrides
|
||||
rm -f .env.local .env.*.local
|
||||
|
||||
# Build the web app
|
||||
echo "Building web application..."
|
||||
pnpm install --frozen-lockfile
|
||||
|
||||
# For production builds, use empty base URL so the app uses relative paths
|
||||
echo "VITE_API_BASE_URL=" > .env.production.local
|
||||
|
||||
pnpm run build --mode production || {
|
||||
echo "Build with type checking failed, trying without type check..."
|
||||
pnpm exec vite build
|
||||
}
|
||||
|
||||
cd - > /dev/null
|
||||
echo "Web app built: $SRC_DIR/web/dist/"
|
||||
|
||||
echo ""
|
||||
echo "Build complete!"
|
||||
echo " Binary: $BUILD_DIR/$BINARY_NAME"
|
||||
echo " Web App: $SRC_DIR/web/dist/"
|
||||
Reference in New Issue
Block a user