Files
mev-beta/scripts/build.sh
Krypto Kajun 8cba462024 feat(prod): complete production deployment with Podman containerization
- Migrate from Docker to Podman for enhanced security (rootless containers)
- Add production-ready Dockerfile with multi-stage builds
- Configure production environment with Arbitrum mainnet RPC endpoints
- Add comprehensive test coverage for core modules (exchanges, execution, profitability)
- Implement production audit and deployment documentation
- Update deployment scripts for production environment
- Add container runtime and health monitoring scripts
- Document RPC limitations and remediation strategies
- Implement token metadata caching and pool validation

This commit prepares the MEV bot for production deployment on Arbitrum
with full containerization, security hardening, and operational tooling.

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 10:15:22 -06:00

104 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Reusable, agnostic build script
# Can be used in any Go project by adjusting configuration
# Configuration variables
BINARY_NAME="${BINARY_NAME:-$(basename "$PWD")}"
BINARY_DIR="${BINARY_DIR:-bin}"
MAIN_FILE="${MAIN_FILE:-cmd/mev-bot/main.go}"
BUILD_TAGS="${BUILD_TAGS:-}"
LDFLAGS="${LDFLAGS:-}"
OUTPUT="${OUTPUT:-$BINARY_DIR/$BINARY_NAME}"
GOOS="${GOOS:-$(go env GOOS)}"
GOARCH="${GOARCH:-$(go env GOARCH)}"
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-n|--name)
BINARY_NAME="$2"
shift 2
;;
-o|--output)
OUTPUT="$2"
shift 2
;;
-m|--main)
MAIN_FILE="$2"
shift 2
;;
-t|--tags)
BUILD_TAGS="$2"
shift 2
;;
-l|--ldflags)
LDFLAGS="$2"
shift 2
;;
--goos)
GOOS="$2"
shift 2
;;
--goarch)
GOARCH="$2"
shift 2
;;
-h|--help)
echo "Usage: $0 [OPTIONS]"
echo "Build a Go application with configurable options"
echo ""
echo "Options:"
echo " -n, --name NAME Binary name (default: current directory name)"
echo " -o, --output PATH Output path (default: bin/BINARY_NAME)"
echo " -m, --main PATH Main package path (default: .)"
echo " -t, --tags TAGS Build tags"
echo " -l, --ldflags FLAGS Ldflags to pass to go build"
echo " --goos OS Target OS (default: $(go env GOOS))"
echo " --goarch ARCH Target architecture (default: $(go env GOARCH))"
echo " -h, --help Show this help"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
echo "Building $BINARY_NAME for $GOOS/$GOARCH..."
# Ensure local Go cache directories exist when not provided
PROJECT_ROOT="$(pwd)"
if [[ -z "${GOCACHE:-}" ]]; then
export GOCACHE="${PROJECT_ROOT}/.gocache"
fi
if [[ -z "${GOMODCACHE:-}" ]]; then
export GOMODCACHE="${PROJECT_ROOT}/.gomodcache"
fi
if [[ -z "${GOPATH:-}" ]]; then
export GOPATH="${PROJECT_ROOT}/.gopath"
fi
if [[ -z "${GOFLAGS:-}" && -d "${PROJECT_ROOT}/vendor" ]]; then
export GOFLAGS="-mod=vendor"
fi
mkdir -p "$GOCACHE" "$GOMODCACHE" "${GOPATH}/pkg/mod"
# Create binary directory
mkdir -p "$(dirname "$OUTPUT")"
# Set environment variables for cross-compilation
export GOOS="$GOOS"
export GOARCH="$GOARCH"
# Build the application
echo "Building $BINARY_NAME..."
[ -n "$BUILD_TAGS" ] && echo " Build tags: $BUILD_TAGS"
[ -n "$LDFLAGS" ] && echo " LDFLAGS: $LDFLAGS"
go build -o "$OUTPUT" ${BUILD_TAGS:+-tags "$BUILD_TAGS"} ${LDFLAGS:+-ldflags "$LDFLAGS"} "$MAIN_FILE"
echo "Build completed successfully!"
echo "Binary: $OUTPUT"