- Cleaned up the `app/web/dist/` directory by deleting an unreferenced and outdated build artifact. - Maintained a lean and organized repository structure.
Orly Web Application
This is a React web application that uses Bun for building and bundling, and is automatically embedded into the Go binary when built.
Prerequisites
- Bun - JavaScript runtime and toolkit
- Go 1.16+ (for embedding functionality)
Development
There are two ways to develop the web app:
- Standalone (recommended for hot reload)
- Start the Go relay with the embedded web UI disabled so the React app can run on its own dev server with HMR.
- Configure the relay via environment variables:
# In another shell at repo root
export ORLY_WEB_DISABLE=true
# Optional: if you want same-origin URLs, you can set a proxy target and access the relay on the same port
# export ORLY_WEB_DEV_PROXY_URL=http://localhost:5173
# Start the relay as usual
go run .
- Then start the React dev server:
cd app/web
bun install
bun dev
When ORLY_WEB_DISABLE=true is set, the Go server still serves the API and websocket endpoints and sends permissive CORS headers, so the dev server can access them cross-origin. If ORLY_WEB_DEV_PROXY_URL is set, the Go server will reverse-proxy non-/api paths to the dev server so you can use the same origin.
- Embedded (no hot reload)
- Build the web app and run the Go server with defaults:
cd app/web
bun install
bun run build
cd ../../
go run .
Building
The React application needs to be built before compiling the Go binary to ensure that the embedded files are available:
# Build the React application
cd app/web
bun install
bun run build
# Build the Go binary from project root
cd ../../
go build
How it works
- The React application is built to the
app/web/distdirectory - The Go embed directive in
app/web.goembeds these files into the binary - When the server runs, it serves the embedded React app at the root path
Build Automation
You can create a shell script to automate the build process:
#!/bin/bash
# build.sh
echo "Building React app..."
cd app/web
bun install
bun run build
echo "Building Go binary..."
cd ../../
go build
echo "Build complete!"
Make it executable with chmod +x build.sh and run with ./build.sh.