This folder host the codebase that provides a web service to interact with soft serve git server, allowing for soft serve command to be accessible over http.
- Nix package manager
- Rust (will be installed via Nix)
- Soft Serve git server
- Postgres (provided via nix setup using docker)
- Docker and Docker Compose (for Postgres)
Clone the project repository:
git clone [https://github.com/Extheoisah/hxckr-infra.git](https://github.com/Extheoisah/hxckr-infra.git)
cd hxckr-infra
Run cp .env.example .env
to create a .env
file.
Adjust these values as needed to match your configuration.
If you haven't installed Nix yet, please visit:
https://nixos.org/download/
We use flakes to manage the project dependencies. To enable flakes after installing nix, add
experimental-features = nix-command flakes
to your
~/.config/nix/nix.conf
file.
Install Soft Serve: For development, a soft serve executable has been provided in the nix setup for the project so that you don't have to install it separately.
Before initializing Soft Serve, you need to set up the SSH key that will be used to authenticate with the server. This key should be added to the authorized keys in Soft Serve.
Generate new ed_25519 key pair using the following command:
ssh-keygen -t ed25519 -C "your email or any identifier"
This will generate a new SSH key pair in the default location (~/.ssh/id_ed25519
and ~/.ssh/id_ed25519.pub
).
View the public key using the following command:
cat ~/.ssh/id_ed25519.pub
Copy the public key and add it to
SOFT_SERVE_INITIAL_ADMIN_KEYS
in your .env file. Next is to set config to use your private key for the server. Add the following to your~/.ssh/config
file:
Host soft
HostName localhost
Port 23231
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
Initialize Soft Serve:
soft serve
This will start the Soft Serve server on
localhost:23231
.
After initializing Soft Serve, the default DB is SQLite. You can change the DB to Postgres by setting the
SOFT_SERVE_POSTGRES_DB
in the.env
file. Use this command to view the soft serve postgres provided in the nix setup:echo @SOFT_SERVE_DATABASE_URL
, this will show the postgres url to use in the.env
file. Copy this url and set it soft serve data directory created when you first run soft serve. You should have something like this indata/config.yaml
# The database configuration.
db:
# The database driver to use.
# Valid values are "sqlite" and "postgres".
driver: "postgres"
# The database data source name.
# This is driver specific and can be a file path or connection string.
# Make sure foreign key support is enabled when using SQLite.
data_source: "postgres://soft_serve:[email protected]:5432/soft_serve?sslmode=disable"
In base directory of the project, run the following commands(also exports all the env variable needed for development):
nix develop
Start the soft serve server in nix shell:
soft serve
In another nix shell (you enter nix shell after running nix develop
from the codebase base directory) cd into the git-service
directory:
cd git-service
Run the soft serve wrappper to expose over http:
cargo run
The server should now be running on http://127.0.0.1:8080
.
The server provides the following endpoints:
- Test Connection:
curl http://127.0.0.1:8080
- Create User:
curl -X POST http://127.0.0.1:8080/create_user \
-H "Content-Type: application/json" \
-d '{"username": "testuser"}'
- Create Token:
curl -X POST http://127.0.0.1:8080/create_token \
-H "Content-Type: application/json" \
-d '{"token_name": "testtoken"}'
- Create Repository:
curl -X POST http://127.0.0.1:8080/create_repo \
-H "Content-Type: application/json" \
-d '{"repo_name": "testrepo", "repo_url": "https://github.com/user/repo.git"}'
To format your code run this in git-service directory:
cargo fmt
If you encounter any issues with SSH connections, ensure that:
- Soft Serve is running
- The SSH key specified in
SOFTSERVE_KEY_PATH
exists and has the correct permissions - The SSH key is added to Soft Serve's authorized keys