|
| 1 | +LFS Test Server |
| 2 | +====== |
| 3 | + |
| 4 | +[rel]: https://github.com/github/lfs-test-server/releases |
| 5 | +[lfs]: https://github.com/github/git-lfs |
| 6 | +[api]: https://github.com/github/git-lfs/tree/master/docs/api#readme |
| 7 | + |
| 8 | +LFS Test Server is an example server that implements the [Git LFS API][api]. It |
| 9 | +is intended to be used for testing the [Git LFS][lfs] client and is not in a |
| 10 | +production ready state. |
| 11 | + |
| 12 | +LFS Test Server is written in Go, with pre-compiled binaries available for Mac, |
| 13 | +Windows, Linux, and FreeBSD. |
| 14 | + |
| 15 | +See [CONTRIBUTING.md](CONTRIBUTING.md) for info on working on LFS Test Server and |
| 16 | +sending patches. |
| 17 | + |
| 18 | +## Installing |
| 19 | + |
| 20 | +Use the Go installer: |
| 21 | + |
| 22 | +``` |
| 23 | + $ go install github.com/git-lfs/lfs-test-server |
| 24 | +``` |
| 25 | + |
| 26 | + |
| 27 | +## Building |
| 28 | + |
| 29 | +To build from source, use the Go tools: |
| 30 | + |
| 31 | +``` |
| 32 | + $ go get github.com/git-lfs/lfs-test-server |
| 33 | +``` |
| 34 | + |
| 35 | + |
| 36 | +## Running |
| 37 | + |
| 38 | +Running the binary will start an LFS server on `localhost:8080` by default. |
| 39 | +There are few things that can be configured via environment variables: |
| 40 | + |
| 41 | + LFS_LISTEN # The address:port the server listens on, default: "tcp://:8080" |
| 42 | + LFS_HOST # The host used when the server generates URLs, default: "localhost:8080" |
| 43 | + LFS_METADB # The database file the server uses to store meta information, default: "lfs.db" |
| 44 | + LFS_CONTENTPATH # The path where LFS files are store, default: "lfs-content" |
| 45 | + LFS_ADMINUSER # An administrator username, default: not set |
| 46 | + LFS_ADMINPASS # An administrator password, default: not set |
| 47 | + LFS_CERT # Certificate file for tls |
| 48 | + LFS_KEY # tls key |
| 49 | + LFS_SCHEME # set to 'https' to override default http |
| 50 | + LFS_USETUS # set to 'true' to enable tusd (tus.io) resumable upload server; tusd must be on PATH, installed separately |
| 51 | + LFS_TUSHOST # The host used to start the tusd upload server, default "localhost:1080" |
| 52 | + |
| 53 | +If the `LFS_ADMINUSER` and `LFS_ADMINPASS` variables are set, a |
| 54 | +rudimentary admin interface can be accessed via |
| 55 | +`http://$LFS_HOST/mgmt`. Here you can add and remove users, which must |
| 56 | +be done before you can use the server with the client. If either of |
| 57 | +these variables are not set (which is the default), the administrative |
| 58 | +interface is disabled. |
| 59 | + |
| 60 | +To use the LFS test server with the Git LFS client, configure it in the repository's `.lfsconfig`: |
| 61 | + |
| 62 | + |
| 63 | +``` |
| 64 | + [lfs] |
| 65 | + url = "http://localhost:8080/" |
| 66 | +
|
| 67 | +``` |
| 68 | + |
| 69 | +HTTPS: |
| 70 | + |
| 71 | +NOTE: If using https with a self signed cert also disable cert checking in the client repo. |
| 72 | + |
| 73 | +``` |
| 74 | + [lfs] |
| 75 | + url = "https://localhost:8080/" |
| 76 | +
|
| 77 | + [http] |
| 78 | + sslverify = false |
| 79 | +
|
| 80 | +``` |
| 81 | + |
| 82 | + |
| 83 | +An example usage: |
| 84 | + |
| 85 | + |
| 86 | +Generate a key pair |
| 87 | +``` |
| 88 | +openssl req -x509 -sha256 -nodes -days 2100 -newkey rsa:2048 -keyout mine.key -out mine.crt |
| 89 | +``` |
| 90 | + |
| 91 | +Make yourself a run script |
| 92 | + |
| 93 | +``` |
| 94 | +#!/bin/bash |
| 95 | +
|
| 96 | +set -eu |
| 97 | +set -o pipefail |
| 98 | +
|
| 99 | +
|
| 100 | +LFS_LISTEN="tcp://:9999" |
| 101 | +LFS_HOST="127.0.0.1:9999" |
| 102 | +LFS_CONTENTPATH="content" |
| 103 | +LFS_ADMINUSER="<cool admin user name>" |
| 104 | +LFS_ADMINPASS="<better admin password>" |
| 105 | +LFS_CERT="mine.crt" |
| 106 | +LFS_KEY="mine.key" |
| 107 | +LFS_SCHEME="https" |
| 108 | +
|
| 109 | +export LFS_LISTEN LFS_HOST LFS_CONTENTPATH LFS_ADMINUSER LFS_ADMINPASS LFS_CERT LFS_KEY LFS_SCHEME |
| 110 | +
|
| 111 | +./lfs-test-server |
| 112 | +
|
| 113 | +``` |
| 114 | + |
| 115 | +Build the server |
| 116 | + |
| 117 | +``` |
| 118 | +go build |
| 119 | +
|
| 120 | +``` |
| 121 | + |
| 122 | +Run |
| 123 | + |
| 124 | +``` |
| 125 | +bash run.sh |
| 126 | +
|
| 127 | +``` |
| 128 | + |
| 129 | +Check the managment page |
| 130 | + |
| 131 | +browser: https://localhost:9999/mgmt |
| 132 | + |
| 133 | + |
0 commit comments