🏡 index : ~doyle/rgit.git

author Jordan Doyle <jordan@doyle.la> 2023-08-14 13:59:53.0 +01:00:00
committer Jordan Doyle <jordan@doyle.la> 2023-08-14 14:13:05.0 +01:00:00
commit
3ee96fb5bc8369dfcfec2b0d3f051cc69e8bd221 [patch]
tree
84e23d8706e3d42a6f7310ac234ee4ec2bb98dbe
parent
fe41118a177236a4a878ddbfea6d5f5a1cb998dc
download
3ee96fb5bc8369dfcfec2b0d3f051cc69e8bd221.tar.gz

Add installation instructions



Diff

 .dockerignore                        |  1 +
 Dockerfile                           | 15 +++++++++++++++
 README.md                            | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 .github/workflows/docker-publish.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 124 insertions(+)

diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..eb5a316 100644
--- /dev/null
+++ a/.dockerignore
@@ -1,0 +1,1 @@
target
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..d68762c 100644
--- /dev/null
+++ a/Dockerfile
@@ -1,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
+++ a/README.md
@@ -13,6 +13,11 @@

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:

```

@@ -40,4 +45,62 @@

    -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
```

diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
new file mode 100644
index 0000000..70f29cf 100644
--- /dev/null
+++ a/.github/workflows/docker-publish.yml
@@ -1,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 }}