21 August 2023

Soft Serve now supports Git LFS and More!

By Ayman Bagabas

Soft Serve mascot

Soft Serve

  • ConsistencySmooth

The mighty, self-hostable Git server for the command line

At Charm, we use Git LFS all the time to bring large files into version control. This very website uses Git LFS to manage video and image assets in the repository and download them during the deployment pipeline. Git LFS stands for “Git Large File Storage” and it is widely supported by many open source and commercial servers.

Git LFS works by using text pointers inside Git repositories while storing the actual file contents on a different server (for example, S3).

In this release, we are pleased to introduce not only Git LFS support, but also collaborator access levels, HTTP authentication, and Postgres database support. Read on for details!

Git LFS Support Over HTTP and SSH

You can now leverage Git LFS in Soft Serve to manage large files over both HTTP and SSH transports, allowing you to handle large files within your repositories without unnecessarily bogging down your clones. Git LFS API relies on a separate HTTPS server to handle transferring the files. The pure-SSH transfer protocol was introduced in Git LFS v3.0. Soft Serve supports both protocols.

git lfs track *.png
git add -A
git push origin main

Soft Serve also supports Git LFS locks.

# As user "tomato" we run
git lfs lock path/to/file
git lfs locks
# path/to/file	tomato	ID:1

Collaborator Access Levels

Adding collaborators is more flexible than ever. Now, you can assign a specific access level to repository collaborators. All you need to do is specify the access level in your repo collab command.

Let’s say you want to make a user read a private repository without giving them the ability to push files and make changes. You could do so by adding a new collaborator with read-only access. To add a collaborator frankie to the repo foobar:

ssh git.example.com repo collab add foobar frankie read-only

Imagine you want to make frankie read all the repositories under docs, you could do something like this:

repos=$(ssh git.example.com repo ls | grep "^docs/") # Get all the repos under docs/
while IFS= read -r repo; do
    ssh git.example.com repo collab add $repo frankie read-only
done <<< $repos

Here, the access level parameter is optional and defaults to read-write access when not specified.

HTTP Authentication

Whether you use Git over HTTP(s), SSH, or both, Soft Serve has you covered. You can use user access tokens to authenticate over HTTP(s). Use the SSH token command to manage your access tokens. Then use the generated tokens as either your HTTP username or password to authenticate and access your repositories.

To generate a new token:

ssh git.example.com token create 'my new token'
# ss_1234abc56789012345678901234de246d798fghi

# Or with an expiry date
ssh git.example.com token create --expires-in 1y 'my other token'
# ss_98fghi1234abc56789012345678901234de246d7

For example, to clone a private repository fajitas with an access token:

git clone https://ss_4db594cxxxxxx@git.example.com/fajitas.git

Postgres

You can now use Postgres instead of SQLite to store persistent data. SQLite is great for a simple and lightweight applications. If you’re using Soft Serve as a single user, perhaps SQLite is all you need. However, if you want to use a more powerful and scalable database engine, Postgres has your back.

Soft Serve uses SQLite as its default database engine. To use Postgres instead, first create a new database for Soft Serve. Then configure Soft Serve to use Postgres as its database engine.

# Create a Soft Serve database
psql -hlocalhost -p5432 -Upostgres -c 'CREATE DATABASE soft_serve'

Now once you have a Soft Serve database, configure your server to use Postgres. In your config.yaml, head to the db section to configure your database settings. Add the section if it doesn’t exist.

db:
  driver: "postgres"
  data_source: "postgres://postgres@localhost:5432/soft_serve?sslmode=disable"

Or if you’re using environment variables to configure your server:

SOFT_SERVE_DB_DRIVER=postgres \
SOFT_SERVE_DB_DATA_SOURCE="postgres://postgres@localhost:5432/soft_serve?sslmode=disable" \
soft serve

For more information, see Soft Serve Database Configuration.

Other Enhancements

Along with all these great features, Soft Serve v0.6 brings lots of bug fixes, better error handling, and improved performance. Check out the release page for a full list of changes.


What are you waiting for! Head to the Soft Serve releases page to grab the latest release.

Soft Serve mascot

Soft Serve

  • ConsistencySmooth

The mighty, self-hostable Git server for the command line

EOF

Read this post in your terminal with Glow:

glow -p https://charm.sh/blog/soft-serve-git-lfs-support.md Copied!

By Ayman Bagabas

21 August 2023

Ayman is a software developer and DevOps engineer at Charm. He designs & manages Charm infrastructure.

Lets chat!

Have a question about a command line thing you’re building? Got an idea for a new feature? Just wanna hang out? You’re always welcome in the Charm Discord.