8000 GitHub - elonen/djlfs-server: Git LFS (batch API) implementation in Django
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

elonen/djlfs-server

 
 

Repository files navigation

DJLFS – Git LFS (batch API) implementation in Django

This is a Django implementation of Git LFS server. It supports basic upload / download through the batch API.

Quick start

The easiest way to get rolling is running the automated tests. I'm developing on OSX, but Linux probably works just as well.

OPTION 1: Run tests with local Git repository

  1. Install Git LFS and Python 3 (including pyvenv command)
  2. ./setup_and_run.sh
  3. If the server starts ok, open a new shell (or hit Ctrl-Z and put it in background with bg)
  4. ./test_git_lfs.sh

This option does a little more thorough tests than WSGI one, as it has direct access to the LFS storage dir it creates in test_temp/lfs_storage_dir/tmp (peek in after running the test to see how the files are stored). It only supports one repository, though.

OPTION 2: Run test with NGINX + uWSGI using Vagrant

  1. Install Vagrant
  2. cd wsgi-test && vagrant up
  3. Open https://127.0.0.1:44300/ in a browser and accept the self-signed test certificate. You should see Debian/NGINX default page (served from inside Vagrant VM).
  4. cd.. ; ./test_git_lfs.sh https://127.0.0.1:44300/git/repo1

You can repeat the last step for repo2 and repo3 if you wish – the included server configuration supports multiple repositories, and stores their large files in separate directories. Do vagrant ssh from wsgi-test directory, and look in /opt/ to see what they look like.

Features

  • Batch server only needs a directory for storing files, no database
  • By design, no authentication, repository management or HTTPS – this is intended as a web server backend with security mostly handled by HTTPD

Installing on NGINX

See wsgi-test/vagrant_bootstrap.sh to see how to set up the server from scratch on a vanilla Debian Stretch (with git-lfs package picked from Buster). Then see wsgi-test/lfs_example_nginx_site for an example configuration file.

The example sets up a Git server for multiple repositories over HTTP (NGINX + fastcgi + git-http-backend) as well as the LFS server, but you can fully well omit it, and only use the LFS server if you wish.

Multiple repository support

The LFS batch server always thinks it's serving files to/from a single LFS repository. Separating them happens on HTTPD. See wsgi-test/lfs_example_nginx_site for an example. It extracts repository name from request URL and sets two environment variables before calling the Django app:

  • DJLFS_BATCH_LOCAL_STORAGE_DIR – Directory where current LFS repository's content is stored.
  • DJLFS_BATCH_LOCAL_STORAGE_HTTP_URL_TEMPLATE_GET – An URL template to GET LFS objects directly through NGINX, bypassing Django for superior performance. The NGINX configuration example shows how to make it efficiently block download attempts that aren't initiated by the LFS batch request.

Checking user authorization

Like authentication, this is also left to the HTTPD.

It sufficies to check authorization for a POST to the batch initialization URI, /info/lfs/objects/batch. It provides Git LFS client with a temporary token (in JWT format), that object GET and PUT handlers then check before allowing download or upload.

Implementation status

  • Batch API works and can be used as a Git LFS server
  • Locking API is not implemented, at least yet

This is a fork of https://github.com/ddanier/django-git-lfs , but I'm most likely going to remove all auth code.

Contributing

Pull requests and issues are welcome.

LFS specs

See:

About

Git LFS (batch API) implementation in Django

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 85.2%
  • Shell 13.2%
  • Ruby 1.6%
0