A reference SvelteKit package for a starter website. This is an incomplete project designed to give a place to start from.
Important
This project is designed to be self-hosted using a persistent filesystem (e.g. VPS, Docker). It uses SQLite and stores raw git repositories on disk. It will not work on serverless platforms like Vercel, Netlify, or Cloudflare Pages.
A lightweight, self-hosted Git service built for speed and simplicity. GitPremo allows you to host repositories, manage organizations, and collaborate with your team using a familiar interface.
- Git Hosting: Full support for
git pushandgit pullover both HTTP and SSH. - Multi-tenancy: Organization and User namespaces, each with their own isolated SQLite database for repository metadata.
- Privacy Controls:
- Private Organizations: Hide your entire organization from the public explore page.
- Private Repositories: Restrict access to specific repositories within an organization.
- Explore: Discover public repositories and organizations across the instance.
- SSH Key Management: Users can manage multiple SSH keys for secure access.
- User Profiles: Customizable profiles and settings.
- Runtime: Bun
- Framework: SvelteKit (using Svelte 5)
- Database: SQLite with Drizzle ORM
- Authentication: Better Auth
- Styling: TailwindCSS
- Bun installed.
-
Clone the repository:
git clone git@github.com:maietta/gitpremo.git cd gitpremo -
Install dependencies:
bun install
-
Start the development server:
bun dev
You must set the following environment variables (in a .env file or your deployment platform):
BETTER_AUTH_SECRET: A random string used to sign session tokens.BETTER_AUTH_URL: The full public URL of your instance (e.g.,http://localhost:3000).
To generate a secure secret, you can run:
openssl rand -base64 32The project includes a Dockerized SSH server configuration for testing git-over-ssh locally.
# Start the SSH test container
docker-compose -f docker-compose.ssh-test.yml up -dThis project includes a production-ready Dockerfile and is designed to be deployed on any platform that supports Docker, such as:
- Coolify
- CapRover
- Dockge
- Portainer
- VPS (via Docker Compose)
[!CAUTION] > GitPremo is NOT compatible with serverless platforms (Vercel, Netlify, Cloudflare Pages, AWS Lambda).
GitPremo requires a persistent filesystem to store SQLite databases and raw git repositories. Serverless environments typically provide ephemeral file systems that are wiped after execution, which would lead to immediate data loss.
To ensure data safety, you must mount a host volume for the /app/data directory.
We strongly recommend configuring an automated backup solution (e.g., a cron job) on the host machine to rsync this volume to an external or offline storage location:
# Example rsync backup command
rsync -avz /path/to/host/data user@backup-server:/path/to/backups/To enable Git operations over SSH on a production Linux server, follow these steps to configure sshd and the git user.
Create a system user that will handle all Git connections.
sudo useradd -r -m -s /bin/bash gitEnsure curl and jq are installed for the helper scripts.
Debian/Ubuntu
sudo apt-get update && sudo apt-get install -y curl jqArch Linux
sudo pacman -Sy curl jqRHEL/CentOS/Fedora
sudo dnf install -y curl jq-
Create Config Directory:
sudo mkdir -p /etc/gitpremo
-
Create Config File (
/etc/gitpremo/config): Adjust the URLs and paths to match your environment.API_URL="http://localhost:5173/api/ssh/keys" AUTH_API_URL="http://localhost:5173/api/ssh/authorize" REPO_ROOT="/path/to/gitpremo/data" # Must match where your app stores data
-
Install Scripts: Copy the host scripts to the system bin locations. Note:
gitpremo-shellMUST be at/usr/bin/gitpremo-shellas specificed in the application code.sudo cp scripts/auth-keys.sh /usr/local/bin/gitpremo-keys sudo cp scripts/shell.sh /usr/bin/gitpremo-shell sudo chmod +x /usr/local/bin/gitpremo-keys /usr/bin/gitpremo-shell
Edit /etc/ssh/sshd_config to tell SSH where to find authorized keys for the git user.
Add the following block to the end of the file:
Match User git
AuthorizedKeysCommand /usr/local/bin/gitpremo-keys
AuthorizedKeysCommandUser nobody
Note: The
Match User gitblock ensures that this dynamic key lookup only applies to thegituser. Normal administrative SSH access for other users (e.g.,root,ubuntu) will continue to work using standard~/.ssh/authorized_keysfiles, even if the GitPremo service is down.
# Debian/Ubuntu
sudo systemctl restart ssh
# Arch/RHEL/Fedora
sudo systemctl restart sshdsrc/lib/server/git: Core git operations handler.src/lib/server/db: Database schema and connection logic (Main DB + Tenant DBs).src/routes/(repos): Repository browsing, organization profiles, and git management routes.src/routes/(profile): User settings and profile management.data/: Storage location for SQLite databases and bare git repositories.
O'Sassy License