Web Platform
The Web platform is the primary deployment target for GreenhouseAdmin. This guide covers building and deploying the application using either the modern Wasm target or the legacy JavaScript target.Overview
GreenhouseAdmin supports two web compilation targets:- Wasm (WebAssembly): Modern, faster runtime using Kotlin/Wasm - Recommended
- JS (JavaScript): Legacy target for older browser support
The Wasm target provides better performance and is recommended for production deployments to modern browsers.
Development
Running the Development Server
- Wasm (Recommended)
- JS (Legacy)
The Wasm target provides the best performance and is the recommended choice for modern browsers.The development server will start at
http://localhost:8080 with hot reload enabled.HTTP Client Configuration
The web targets use the Ktor JS engine for network requests:composeApp/build.gradle.kts
Production Build
Building for Production
Build Production Distribution
Build the optimized production bundle:Output location:
- Wasm
- JS
composeApp/build/dist/wasmJs/productionExecutable/Deployment
Nginx Configuration
The project includes a production-ready Nginx configuration with optimizations for Wasm applications.Key Nginx Features
Key Nginx Features
- Wasm MIME Type: Properly configured
application/wasmtype - COOP/COEP Headers: Required for
SharedArrayBuffersupport (needed by Skiko/Compose) - Smart Caching: Aggressive caching for hashed assets, revalidation for entry points
- SPA Routing: Fallback to
index.htmlfor client-side routing - Gzip Compression: Including
.wasmfiles - Security Headers: XSS protection, frame options, content type sniffing prevention
Critical Headers for Wasm
Critical Headers for Wasm
nginx.conf
Caching Strategy
Caching Strategy
nginx.conf
nginx.conf in the project root.
Docker Deployment
The project includes a multi-stage Dockerfile for containerized deployments.Run Container
Run the containerized application:The application will be available at
http://localhost.Dockerfile Structure
Dockerfile Structure
The multi-stage build process:Stage 1 - Builder (
gradle:8.10-jdk21):- Installs
libatomic1(required for Node.js v25+ used by Kotlin/Wasm) - Copies Gradle configuration and source code
- Creates
local.propertieswithAPI_BASE_URLfrom build argument - Upgrades Yarn lock files
- Builds Wasm production distribution
nginx:alpine):- Copies custom Nginx configuration
- Copies built Wasm application from builder stage
- Exposes port 80 with health check endpoint
Dockerfile in project rootEnvironment Configuration
The application uses BuildKonfig to inject environment-specific configuration at compile time:composeApp/build.gradle.kts
Browser Compatibility
Wasm Target
Minimum Browser Versions:- Chrome/Edge 119+
- Firefox 120+
- Safari 17.4+
Wasm GC support is required. Older browsers will not work with the Wasm target.
JS Target
Minimum Browser Versions:- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
Troubleshooting
SharedArrayBuffer is not defined
SharedArrayBuffer is not defined
Wasm file fails to load
Wasm file fails to load
Cause: Incorrect MIME type configurationSolution: Add the Wasm MIME type to your server:
Build fails with Yarn errors
Build fails with Yarn errors
Cause: Outdated lock files after dependency changesSolution: Upgrade Yarn lock files:
Out of memory during build
Out of memory during build
Cause: Insufficient JVM heap for GradleSolution: Increase Gradle memory in
gradle.properties:Next Steps
Android Platform
Build and deploy to Android devices
iOS Platform
Build and deploy to iOS devices
Desktop Platform
Build native desktop applications
Architecture
Learn about the app architecture