This guide covers building each component of Anchor for production use. Whether you’re deploying the server, web app, or mobile app, you’ll find the necessary build commands and configurations here.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ZhFahim/anchor/llms.txt
Use this file to discover all available pages before exploring further.
Building the Server
The server is a NestJS application that compiles TypeScript to JavaScript.Development Build
Production Build
The production start command (
start:prod) runs node dist/src/main, which starts the compiled server on the configured PORT (default: 3001).Environment Variables
Ensure these are set for production:Build Scripts
Fromserver/package.json:
| Command | Description |
|---|---|
pnpm build | Compile TypeScript to JavaScript |
pnpm start | Start server (requires build) |
pnpm start:dev | Start in development mode with watch |
pnpm start:prod | Start production server |
pnpm lint | Run ESLint |
pnpm test | Run unit tests |
pnpm test:e2e | Run end-to-end tests |
Building the Web App
The web app is a Next.js 16 application that can be built for static export or as a Node.js server.Development Build
Production Deployment
The web app requires the server to be running and accessible. Configure the
SERVER_URL environment variable if the server is not on the default http://127.0.0.1:3001.Build Optimization
Next.js automatically:- Minifies JavaScript and CSS
- Optimizes images with next/image
- Splits code for optimal loading
- Generates static pages where possible
- Creates a service worker for offline support (if configured)
Build Scripts
Fromweb/package.json:
| Command | Description |
|---|---|
pnpm dev | Start development server on :3000 |
pnpm build | Create production build |
pnpm start | Start production server |
pnpm lint | Run ESLint |
Environment Variables
Building the Mobile App
The mobile app is built with Flutter and supports Android and iOS.Prerequisites
- Flutter SDK installed and configured
- For Android: Android SDK and NDK
- For iOS: Xcode and CocoaPods (macOS only)
Android Build
Run code generation
- Riverpod providers
- Drift database tables
- JSON serialization
- Freezed data classes
Build APK
Split APKs create smaller files for specific CPU architectures (arm64-v8a, armeabi-v7a, x86_64). The universal APK works on all devices but is larger.
iOS Build
Build Configuration
Frommobile/pubspec.yaml:
major.minor.patch+buildNumber.
Flutter Build Commands
| Command | Description |
|---|---|
flutter pub get | Install dependencies |
flutter run | Run in development mode |
flutter build apk | Build Android APK |
flutter build appbundle | Build Android App Bundle |
flutter build ios | Build iOS app |
dart run build_runner build | Generate code |
flutter clean | Clean build cache |
Docker Builds
Anchor provides Docker configurations for easy deployment.Development Build
Use the development Docker Compose file:- PostgreSQL database
- Server with hot reload
- Web app with hot reload
Production Build
Build the production image
- Builds the server (NestJS)
- Builds the web app (Next.js)
- Combines them in a single container
- Includes embedded PostgreSQL (PGlite)
Using Pre-built Image
Build Verification
After building, verify each component:Server
Web
Visithttp://localhost:3000 and verify:
- Pages load correctly
- Assets are minified
- API requests work
- Authentication flow works
Mobile
Test the built APK/IPA:- Install on a physical device or emulator
- Verify offline functionality
- Test sync with server
- Check performance and stability
Build Troubleshooting
Server Build Errors
Web Build Errors
Mobile Build Errors
Performance Considerations
Server
- Enable production mode (
NODE_ENV=production) - Use connection pooling for PostgreSQL
- Configure appropriate memory limits
- Enable gzip compression
Web
- Ensure
next buildruns successfully - Enable compression middleware
- Use CDN for static assets
- Configure caching headers
Mobile
- Use
--releaseflag for production builds - Enable ProGuard for Android (code shrinking)
- Optimize images and assets
- Test on real devices for performance
Continuous Integration
Example GitHub Actions workflow:Next Steps
- Review the contribution guidelines before submitting changes
- Learn about the architecture to understand the codebase
- Return to getting started for development setup