···11+# SimpleLink
22+A very performant and light (6mb in memory) link shortener and tracker. Written in Rust and React and uses Postgres.
33+44+
55+66+
77+88+## Build
99+1010+### From Source
1111+First configure .env.example and save it to .env
1212+1313+The project will not run withot DATABASE_URL set. (TODO add sqlite support)
1414+1515+```bash
1616+#set api-domain to where you will be deploying the link shortener, eg: link.example.com, default is localhost:8080
1717+git clone https://github.com/waveringana/simplelink && cd simplelink
1818+./build.sh api-domain=localhost:8080
1919+cargo run
2020+```
2121+2222+Alternatively if you want a binary form
2323+```bash
2424+./build.sh --binary
2525+```
2626+then check /target/release for the binary named `SimpleGit`
2727+2828+### From Docker
2929+```bash
3030+docker build --build-arg API_URL=http://localhost:8080 -t simplelink .
3131+docker run simplelink -p 8080:8080 \
3232+ -e JWT_SECRET=change-me-in-production \
3333+ -e DATABASE_URL=postgres://user:password@host:port/database \
3434+ simplelink
3535+```
3636+3737+### From Docker Compose
3838+Adjust the included docker-compose.yml to your liking, it includes a postgres config as well.
+9-7
build.sh
···33# Default values
44API_URL="http://localhost:8080"
55RELEASE_MODE=false
66+BINARY_MODE=false
6778# Parse command line arguments
89for arg in "$@"
···1415 ;;
1516 --release)
1617 RELEASE_MODE=true
1818+ shift
1919+ ;;
2020+ --binary)
2121+ BINARY_MODE=true
1722 shift
1823 ;;
1924 esac
···4550npm run build
4651cd ..
47524848-# Create static directory if it doesn't exist
5353+# Create static directory and copy frontend build
4954mkdir -p static
5050-5151-# Clean existing static files
5255rm -rf static/*
5353-5454-# Copy built files to static directory
5556cp -r frontend/dist/* static/
56575758# Build Rust project
···6263 # Create release directory
6364 mkdir -p release
64656565- # Copy binary and static files to release directory
6666+ # Copy only the binary to release directory
6667 cp target/release/simplelink release/
6767- cp -r static release/
6868 cp .env.example release/.env
69697070 # Create a tar archive
7171 tar -czf release.tar.gz release/
72727373 echo "Release archive created: release.tar.gz"
7474+elif [ "$BINARY_MODE" = true ]; then
7575+ cargo build --release
7476else
7577 cargo build
7678fi