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