gitscope
← rgit / Diff · 3ee96fb → 3ee96fb
Changes 3ee96fb..3ee96fb
Patch commit
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..eb5a316
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+target
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
new file mode 100644
index 0000000..70f29cf
--- /dev/null
+++ b/.github/workflows/docker-publish.yml
@@ -0,0 +1,45 @@
+name: Docker
+
+on:
+ schedule:
+ - cron: '45 20 * * *'
+ push:
+ branches: [ main ]
+
+env:
+ # Use docker.io for Docker Hub if empty
+ REGISTRY: ghcr.io
+ # github.repository as <account>/<repo>
+ IMAGE_NAME: ${{ github.repository }}
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ packages: write
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+ - name: Setup Docker buildx
+ uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
+ - name: Log into registry ${{ env.REGISTRY }}
+ if: github.event_name != 'pull_request'
+ uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Extract Docker metadata
+ id: meta
+ uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
+ with:
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+ - name: Build and push Docker image
+ id: build-and-push
+ uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
+ with:
+ context: .
+ push: ${{ github.event_name != 'pull_request' }}
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..d68762c
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,15 @@
+FROM rust:1.71-slim AS builder
+
+RUN apt-get update && apt-get install -y libssl-dev pkg-config
+
+COPY . /sources
+WORKDIR /sources
+RUN cargo build --release
+RUN chown nobody:nogroup /sources/target/release/rgit
+
+FROM debian:bullseye-slim
+COPY --from=builder /sources/target/release/rgit /rgit
+
+USER nobody
+EXPOSE 8000
+ENTRYPOINT ["/rgit", "[::]:8000", "/git", "-d", "/tmp/rgit-cache.db"]
diff --git a/README.md b/README.md
index 9225074..60dd342 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,11 @@ included for rendered READMEs and diffs.
Includes a dark mode for late night committing.
+Your `SCAN_PATH` should contain (optionally nested) [bare repositories][], and a `config` file
+can be written with a `[gitweb.owner]` key to signify ownership.
+
+[bare repositories]: https://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server
+
Usage:
```
@@ -41,3 +46,61 @@ OPTIONS:
-V, --version
Print version information
```
+
+### Installation
+
+#### From Source
+
+rgit can be installed from source by cloning, building using [`cargo`][] and running the binary:
+
+```bash
+$ git clone https://github.com/w4/rgit
+$ cd rgit
+$ cargo build --release
+$ ./target/release/rgit [::]:3333 /path/to/my-repos -d /tmp/rgit-cache.db
+```
+
+[`cargo`]: https://www.rust-lang.org/
+
+#### NixOS
+
+Running rgit on NixOS is extremely simple, simply import the module into your `flake.nix` and use the
+provided service:
+
+```nix
+{
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
+
+ rgit = {
+ url = "github:w4/rgit";
+ inputs.nixpkgs = "nixpkgs";
+ };
+ };
+
+ outputs = { nixpkgs, ... }: {
+ nixosConfigurations.mySystem = nixpkgs.lib.nixosSystem {
+ modules = [
+ rgit.nixosModules.default
+ {
+ services.rgit = {
+ enable = true;
+ bindAddress = "[::]:3333";
+ dbStorePath = "/tmp/rgit.db";
+ repositoryStorePath = "/path/to/my-repos";
+ };
+ }
+ ...
+ ];
+ };
+ };
+}
+```
+
+#### Docker
+
+Running rgit in Docker is also simple, just mount the directory containing your repositories to `/git`:
+
+```bash
+$ docker run --mount type=bind,source=/path/to/my-repos,target=/git -it ghcr.io/w4/rgit:main
+```