Skip to content

Manual Compilation

Build ElasticView from source code for custom configurations, development, or when pre-built binaries are not available for your platform.

Prerequisites

Required Tools

  • Go: Version 1.19 or higher
  • Node.js: Version 16 or higher
  • npm or yarn: Package manager
  • Git: For cloning the repository

System Requirements

  • RAM: 4GB or more (for compilation)
  • Storage: 2GB free space
  • OS: Linux, macOS, or Windows

Build Steps

1. Clone Repository

bash
git clone https://github.com/1340691923/ElasticView.git
cd ElasticView

2. Install Dependencies

Frontend Dependencies

bash
cd web
npm install
# or
yarn install

Backend Dependencies

bash
cd ../
go mod download

3. Build Frontend

bash
cd web
npm run build
# or
yarn build

4. Build Backend

bash
cd ../
go build -o elasticview main.go

5. Run ElasticView

bash
./elasticview

Advanced Build Options

Cross-Platform Compilation

For Linux

bash
GOOS=linux GOARCH=amd64 go build -o elasticview-linux-amd64 main.go

For Windows

bash
GOOS=windows GOARCH=amd64 go build -o elasticview-windows-amd64.exe main.go

For macOS

bash
GOOS=darwin GOARCH=amd64 go build -o elasticview-darwin-amd64 main.go

Optimized Build

bash
go build -ldflags="-s -w" -o elasticview main.go

With Version Information

bash
go build -ldflags="-X main.version=v1.0.0 -X main.buildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o elasticview main.go

Development Setup

Hot Reload Development

Backend (with air)

bash
# Install air for hot reload
go install github.com/cosmtrek/air@latest

# Run with hot reload
air

Frontend

bash
cd web
npm run dev
# or
yarn dev

Running Tests

bash
# Run all tests
go test ./...

# Run with coverage
go test -cover ./...

# Frontend tests
cd web
npm test

Build Scripts

Create a build script for automation:

Linux/macOS (build.sh)

bash
#!/bin/bash

echo "Building ElasticView..."

# Build frontend
echo "Building frontend..."
cd web
npm install
npm run build
cd ..

# Build backend
echo "Building backend..."
go mod download
go build -ldflags="-s -w" -o elasticview main.go

echo "Build complete!"

Windows (build.bat)

batch
@echo off
echo Building ElasticView...

echo Building frontend...
cd web
npm install
npm run build
cd ..

echo Building backend...
go mod download
go build -ldflags="-s -w" -o elasticview.exe main.go

echo Build complete!

Troubleshooting

Go Module Issues

bash
go clean -modcache
go mod download

Node.js Memory Issues

bash
export NODE_OPTIONS="--max-old-space-size=4096"
npm run build

Permission Issues

bash
chmod +x build.sh
./build.sh

Contributing

Development Workflow

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests
  5. Submit a pull request

Code Standards

  • Follow Go conventions
  • Use gofmt for formatting
  • Add tests for new features
  • Update documentation

Next Steps