A very performant and light (2mb in memory) link shortener and tracker. Written in Rust and React and uses Postgres/SQLite.
1#!/bin/bash 2 3# Default values 4API_URL="http://localhost:8080" 5RELEASE_MODE=false 6 7# Parse command line arguments 8for arg in "$@" 9do 10 case $arg in 11 api-domain=*) 12 API_URL="${arg#*=}" 13 shift 14 ;; 15 --release) 16 RELEASE_MODE=true 17 shift 18 ;; 19 esac 20done 21 22echo "Building project with API_URL: $API_URL" 23echo "Release mode: $RELEASE_MODE" 24 25# Check if cargo is installed 26if ! command -v cargo &> /dev/null; then 27 echo "cargo is not installed. Please install Rust and cargo first." 28 exit 1 29fi 30 31# Check if npm is installed 32if ! command -v npm &> /dev/null; then 33 echo "npm is not installed. Please install Node.js and npm first." 34 exit 1 35fi 36 37# Build frontend 38echo "Building frontend..." 39# Create .env file for Vite 40echo "VITE_API_URL=$API_URL" > frontend/.env 41 42# Install frontend dependencies and build 43cd frontend 44npm install 45npm run build 46cd .. 47 48# Create static directory if it doesn't exist 49mkdir -p static 50 51# Clean existing static files 52rm -rf static/* 53 54# Copy built files to static directory 55cp -r frontend/dist/* static/ 56 57# Build Rust project 58echo "Building Rust project..." 59if [ "$RELEASE_MODE" = true ]; then 60 cargo build --release 61 62 # Create release directory 63 mkdir -p release 64 65 # Copy binary and static files to release directory 66 cp target/release/simplelink release/ 67 cp -r static release/ 68 cp .env.example release/.env 69 70 # Create a tar archive 71 tar -czf release.tar.gz release/ 72 73 echo "Release archive created: release.tar.gz" 74else 75 cargo build 76fi 77 78echo "Build complete!" 79echo "To run the project:" 80if [ "$RELEASE_MODE" = true ]; then 81 echo "1. Extract release.tar.gz" 82 echo "2. Configure .env file" 83 echo "3. Run ./simplelink" 84else 85 echo "1. Configure .env file" 86 echo "2. Run 'cargo run'" 87fi