Kaynağa Gözat

Merge pull request #88 from overleaf/jpa-docker-image

[misc] docker image
Shane Kilkelly 5 yıl önce
ebeveyn
işleme
6d44851869

+ 6 - 0
services/git-bridge/.dockerignore

@@ -0,0 +1,6 @@
+*
+!/lib
+!/src/main
+!/pom.xml
+!/Makefile
+!/LICENSE

+ 29 - 2
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

+ 21 - 10
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 <path_to_jar> <path_to_config_file>` to run the server.
 
-Runtime Configuration
----------------------
+## Runtime Configuration
 
 The configuration file is in `.json` format.