A very performant and light (2mb in memory) link shortener and tracker. Written in Rust and React and uses Postgres/SQLite.
1#!/bin/bash 2set -e 3 4# Default environment is production 5ENV=${ENV:-production} 6echo "Building for environment: $ENV" 7 8# Load environment variables from the appropriate .env file 9if [ -f "frontend/.env.$ENV" ]; then 10 echo "Loading environment variables from frontend/.env.$ENV" 11 export $(cat frontend/.env.$ENV | grep -v '^#' | xargs) 12else 13 echo "Warning: No .env.$ENV file found in frontend directory" 14fi 15 16# Allow override of VITE_API_URL through command line 17VITE_API_URL=${VITE_API_URL:-${VITE_API_URL:-http://localhost:3000}} 18echo "Using API URL: $VITE_API_URL" 19 20echo "Building frontend..." 21cd frontend 22bun install 23 24# Export variables for Vite to pick up 25export VITE_API_URL 26export NODE_ENV=$ENV 27 28echo "Running build..." 29bun run build 30 31echo "Copying static files..." 32cd .. 33rm -rf static 34mkdir -p static 35cp -r frontend/dist/* static/ 36 37echo "Build complete!" 38 39# Usage information if no arguments provided 40if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then 41 echo "Usage:" 42 echo " ./build.sh # Builds with production environment" 43 echo " ENV=development ./build.sh # Builds with development environment" 44 echo " VITE_API_URL=https://api.example.com ./build.sh # Overrides API URL" 45 echo "" 46 echo "Environment Variables:" 47 echo " ENV - Build environment (development/staging/production)" 48 echo " VITE_API_URL - Override the API URL" 49 exit 0 50fi