diff --git a/services/git-bridge/.dockerignore b/services/git-bridge/.dockerignore new file mode 100644 index 0000000000..e49947d0fd --- /dev/null +++ b/services/git-bridge/.dockerignore @@ -0,0 +1,6 @@ +* +!/lib +!/src/main +!/pom.xml +!/Makefile +!/LICENSE diff --git a/services/git-bridge/Dockerfile b/services/git-bridge/Dockerfile index a309040d63..341535c451 100644 --- a/services/git-bridge/Dockerfile +++ b/services/git-bridge/Dockerfile @@ -1,7 +1,34 @@ # Dockerfile for git-bridge -FROM maven:3-jdk-8 +FROM maven:3-jdk-8 as base -RUN apt-get update && apt-get install -y make git curl +RUN apt-get update && apt-get install -y make \ + && rm -rf /var/lib/apt/lists + +RUN useradd --create-home node + +FROM base as builder WORKDIR /app + +COPY . /app +RUN make package \ +# The name of the created jar contains the current version tag. +# Rename it to a static path that can be used for copying. +&& find /app/target \ + -name 'writelatex-git-bridge*jar-with-dependencies.jar' \ + -exec mv {} /git-bridge.jar \; + +FROM openjdk:8-jre + +RUN apt-get update && apt-get install -y git \ + && rm -rf /var/lib/apt/lists + +RUN useradd --create-home node + +ENTRYPOINT ["java", "-jar", "/git-bridge.jar"] +CMD ["/conf/runtime.json"] + +COPY --from=builder /git-bridge.jar / + +USER node diff --git a/services/git-bridge/README.md b/services/git-bridge/README.md index 038d1b8b3f..744a97aa45 100644 --- a/services/git-bridge/README.md +++ b/services/git-bridge/README.md @@ -1,13 +1,26 @@ -writelatex-git-bridge -===================== +# writelatex-git-bridge + +## Docker + +The `Dockerfile` contains all the requirements for building and running the + writelatex-git-bridge. + +```bash +# 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 -Required --------- * `maven` (for building, running tests and packaging) * `jdk-8` (for compiling and running) -Commands --------- +### Commands To be run from the base directory: @@ -31,8 +44,7 @@ To be run from the dev-environment: **Clean**: `bin/run git-bridge make clean` -Installation ------------- +### Installation Install dependencies: @@ -50,8 +62,7 @@ Run `mvn package` to build, test, and package it into a jar at `target/writelate Use `java -jar ` to run the server. -Runtime Configuration ---------------------- +## Runtime Configuration The configuration file is in `.json` format.