Building Guide
Building Guide
Section titled “Building Guide”Building ION Flow - How to compile and package the application.
Overview
Section titled “Overview”ION Flow consists of multiple Go modules that can be built independently or together.
Prerequisites
Section titled “Prerequisites”| Requirement | Version | Notes |
|---|---|---|
| Go | 1.24.3+ | go version |
| GCC | Any | Required for SQLite CGO |
| Git | 2.x | For version info |
CGO Requirement
Section titled “CGO Requirement”SQLite requires CGO. Ensure you have:
# macOSxcode-select --install
# Linux (Debian/Ubuntu)sudo apt-get install build-essential
# Linux (RHEL/CentOS)sudo yum groupinstall "Development Tools"Building Backend
Section titled “Building Backend”Development Build
Section titled “Development Build”# From project rootgo build -o bin/ion-flow main.go
# Or using go rungo run main.goProduction Build
Section titled “Production Build”# With optimizationsgo build -ldflags="-s -w" -o bin/ion-flow main.go
# With version infoVERSION=$(git describe --tags --always)go build -ldflags="-s -w -X main.Version=${VERSION}" -o bin/ion-flow main.goCross-Compilation
Section titled “Cross-Compilation”# Linux AMD64GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -o bin/ion-flow-linux-amd64 main.go
# Linux ARM64GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go build -o bin/ion-flow-linux-arm64 main.go
# macOS AMD64GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -o bin/ion-flow-darwin-amd64 main.go
# macOS ARM64 (Apple Silicon)GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build -o bin/ion-flow-darwin-arm64 main.goNote: Cross-compilation with CGO requires appropriate cross-compilers.
Building Server
Section titled “Building Server”cd server
# Developmentgo build -o bin/flow-server .
# Productiongo build -ldflags="-s -w" -o bin/flow-server .Building Core Library
Section titled “Building Core Library”The core module is typically used as a library, but can be tested:
cd corego build ./...go test ./...Build Scripts
Section titled “Build Scripts”Makefile
Section titled “Makefile”.PHONY: build build-server clean test
VERSION := $(shell git describe --tags --always)LDFLAGS := -ldflags="-s -w -X main.Version=$(VERSION)"
build: go build $(LDFLAGS) -o bin/ion-flow main.go
build-server: cd server && go build $(LDFLAGS) -o ../bin/flow-server .
clean: rm -rf bin/ rm -f coverage.out
test: go test -cover ./...
all: clean build build-serverBuild Script
Section titled “Build Script”#!/bin/bashset -e
VERSION=$(git describe --tags --always)LDFLAGS="-s -w -X main.Version=${VERSION}"
echo "Building ION Flow v${VERSION}..."
# Cleanrm -rf bin/
# Build backendecho "Building backend..."go build -ldflags="${LDFLAGS}" -o bin/ion-flow main.go
# Build serverecho "Building server..."cd servergo build -ldflags="${LDFLAGS}" -o ../bin/flow-server .cd ..
echo "Build complete!"ls -la bin/Docker Build
Section titled “Docker Build”Dockerfile
Section titled “Dockerfile”# Build stageFROM golang:1.24-alpine AS builder
RUN apk add --no-cache gcc musl-dev
WORKDIR /app
# Copy go.mod filesCOPY go.mod go.sum ./COPY core/go.mod core/go.sum ./core/COPY backend/go.mod backend/go.sum ./backend/COPY packages/helpers/go.mod ./packages/helpers/COPY packages/channel/go.mod packages/channel/go.sum ./packages/channel/COPY server/go.mod server/go.sum ./server/
# Download dependenciesRUN go mod download
# Copy sourceCOPY . .
# BuildRUN CGO_ENABLED=1 go build -ldflags="-s -w" -o /ion-flow main.go
# Runtime stageFROM alpine:latest
RUN apk add --no-cache ca-certificates
WORKDIR /app
COPY --from=builder /ion-flow .
# Create storage directoriesRUN mkdir -p storage/dbs storage/store storage/repos
EXPOSE 8000
CMD ["./ion-flow"]Build Docker Image
Section titled “Build Docker Image”docker build -t ion-flow:latest .docker run -p 8000:8000 -v ./storage:/app/storage ion-flow:latestBuild Optimizations
Section titled “Build Optimizations”Size Reduction
Section titled “Size Reduction”# Strip debug infogo build -ldflags="-s -w" -o bin/ion-flow main.go
# Use UPX compression (if available)upx --best bin/ion-flowBuild Tags
Section titled “Build Tags”# Production buildgo build -tags production -o bin/ion-flow main.go
# With specific featuresgo build -tags "json1 fts5" -o bin/ion-flow main.goVerifying Build
Section titled “Verifying Build”Check Binary
Section titled “Check Binary”# File infofile bin/ion-flow
# Version (if embedded)./bin/ion-flow --version
# Run./bin/ion-flowTest Binary
Section titled “Test Binary”# Quick health checkcurl http://localhost:8000/health
# Or for server./bin/flow-server -port 8080 &curl http://localhost:8080/data-store-listCI/CD Integration
Section titled “CI/CD Integration”GitLab CI/CD Example
Section titled “GitLab CI/CD Example”image: golang:1.24
stages: - test - build
before_script: - apt-get update && apt-get install -y gcc musl-dev
test: stage: test script: - go test -v ./...
build: stage: build script: - go build -ldflags="-s -w" -o bin/ion-flow main.go artifacts: paths: - bin/ion-flow expire_in: 1 weekTroubleshooting
Section titled “Troubleshooting”CGO Errors
Section titled “CGO Errors”# Ensure GCC is installedgcc --version
# Set CGO_ENABLEDCGO_ENABLED=1 go build ...SQLite Errors
Section titled “SQLite Errors”# Install SQLite development headers# Debian/Ubuntusudo apt-get install libsqlite3-dev
# macOS (usually included)# RHEL/CentOSsudo yum install sqlite-develModule Errors
Section titled “Module Errors”# Clean module cachego clean -modcache
# Re-downloadgo mod downloadRelated Documentation
Section titled “Related Documentation”- Development Guide - Development setup
- Deployment Guide - Deployment process
- Testing Guide - Testing