overleaf/services/git-bridge
Eric Mc Sween 4535364ee2 Merge pull request #13387 from overleaf/em-git-bridge-remove-v1-to-v2-conversions
Remove automatic conversion of v1 projects to v2 in git-bridge

GitOrigin-RevId: af0285d98c77f4c9014da5c1d20d7def4b866cde
2023-07-17 10:32:24 +00:00
..
conf Merge pull request #13026 from overleaf/em-git-bridge-password-mode-default 2023-05-12 08:04:24 +00:00
src Merge pull request #13387 from overleaf/em-git-bridge-remove-v1-to-v2-conversions 2023-07-17 10:32:24 +00:00
vendor Configure from env vars at run time 2021-05-07 09:47:49 +01:00
.dockerignore Merge pull request #12371 from overleaf/em-git-bridge-data-directory 2023-03-30 08:03:54 +00:00
.gitignore Configure from env vars at run time 2021-05-07 09:47:49 +01:00
Dockerfile Merge pull request #12371 from overleaf/em-git-bridge-data-directory 2023-03-30 08:03:54 +00:00
LICENSE Initial commit 2014-11-01 16:02:22 +00:00
Makefile Merge pull request #9081 from overleaf/jpa-bring-back-build 2022-08-03 08:04:45 +00:00
pom.xml Merge pull request #12551 from overleaf/msm-git-bridge-vulnerabilites 2023-04-12 08:03:57 +00:00
README.md Merge branch 'master' into jpa-docker-image 2020-12-10 14:28:03 +00:00
server-pro-start.sh Merge pull request #12371 from overleaf/em-git-bridge-data-directory 2023-03-30 08:03:54 +00:00
start.sh Revert "Merge pull request #137 from overleaf/spd-memprof-again" 2021-07-19 10:50:25 +01:00

writelatex-git-bridge

Docker

The Dockerfile contains all the requirements for building and running the writelatex-git-bridge.

# build the image
docker build -t writelatex-git-bridge .

# run it with the demo config
docker run -v `pwd`/conf/local.json:/conf/runtime.json writelatex-git-bridge

Native install

Required packages

  • maven (for building, running tests and packaging)
  • jdk-8 (for compiling and running)

Commands

To be run from the base directory:

Build jar: mvn package

Run tests: mvn test

Clean: mvn clean

To be run from the dev-environment:

Build jar: bin/run git-bridge make package

Run tests: bin/run git-bridge make test

Clean: bin/run git-bridge make clean

Installation

Install dependencies:

sudo apt-get update
sudo apt-get install -y maven
sudo apt-get install -y openjdk-8-jdk
sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/javac

Create a config file according to the format below.

Run mvn package to build, test, and package it into a jar at target/writelatex-git-bridge-1.0-SNAPSHOT-jar-with-dependencies.jar.

Use java -jar <path_to_jar> <path_to_config_file> to run the server.

Runtime Configuration

The configuration file is in .json format.

{
    "port" (int): the port number,
    "rootGitDirectory" (string): the directory in which to store
                                 git repos and the db/atts,
    "apiBaseUrl" (string): base url for the snapshot api,
    "username" (string, optional): username for http basic auth,
    "password" (string, optional): password for http basic auth,
    "postbackBaseUrl" (string): the postback url,
    "serviceName" (string): current name of writeLaTeX
                            in case it ever changes,
    "oauth2" (object): { null or missing if oauth2 shouldn't be used
        "oauth2ClientID" (string): oauth2 client ID,
        "oauth2ClientSecret" (string): oauth2 client secret,
        "oauth2Server" (string): oauth2 server,
                                 with protocol and
                                 without trailing slash
    },
    "repoStore" (object, optional): { configure the repo store
        "maxFileSize" (long, optional): maximum size of a file, inclusive
    },
    "swapStore" (object, optional): { the place to swap projects to.
                                      if null, type defaults to
                                      "noop"
        "type" (string): "s3", "memory", "noop" (not recommended),
        "awsAccessKey" (string, optional): only for s3,
        "awsSecret" (string, optional): only for s3,
        "s3BucketName" (string, optional): only for s3
    },
    "swapJob" (object, optional): { configure the project
                                    swapping job.
                                    if null, defaults to no-op
        "minProjects" (int64): lower bound on number of projects
                               present. The swap job will never go
                               below this, regardless of what the
                               watermark shows. Regardless, if
                               minProjects prevents an eviction,
                               the swap job will WARN,
        "lowGiB" (int32): the low watermark for swapping,
                          i.e. swap until disk usage is below this,
        "highGiB" (int32): the high watermark for swapping,
                           i.e. start swapping when
                           disk usage becomes this,
        "intervalMillis" (int64): amount of time in between running
                                  swap job and checking watermarks.
                                  3600000 is 1 hour
    }
}

You have to restart the server for configuration changes to take effect.

Creating OAuth app

In dev-env, run the following command in mongo to create the oauth application for git-bridge.

db.oauthApplications.insert({
  "clientSecret" : "e6b2e9eee7ae2bb653823250bb69594a91db0547fe3790a7135acb497108e62d",
  "grants" : [
    "password"
  ],
  "id" : "264c723c925c13590880751f861f13084934030c13b4452901e73bdfab226edc",
  "name" : "Overleaf Git Bridge",
  "redirectUris" : [],
  "scopes" : [
    "git_bridge"
  ]
})