Jelajahi Sumber

Generate a config file from env vars and template

Christopher Hoskin 5 tahun lalu
induk
melakukan
f1c9d6108e

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

@@ -1,4 +1,6 @@
 *
+!start.sh
+!/conf
 !/lib
 !/src/main
 !/pom.xml

+ 8 - 3
services/git-bridge/Dockerfile

@@ -21,14 +21,19 @@ RUN make package \
 
 FROM openjdk:8-jre
 
-RUN apt-get update && apt-get install -y git \
+RUN apt-get update && apt-get install -y git gettext-base\
  && rm -rf /var/lib/apt/lists
 
 RUN useradd --create-home node
 
-ENTRYPOINT ["java", "-jar", "/git-bridge.jar"]
-CMD ["/conf/runtime.json"]
+CMD ["/start.sh"]
 
 COPY --from=builder /git-bridge.jar /
 
+COPY conf/envsubst_template.json envsubst_template.json
+COPY start.sh start.sh
+
+RUN mkdir conf
+RUN chown node:node conf
+
 USER node

+ 32 - 0
services/git-bridge/conf/envsubst_template.json

@@ -0,0 +1,32 @@
+{
+    "port": 8080,
+    "rootGitDirectory": "/tmp/wlgb",
+    "apiBaseUrl": "https://localhost/api/v0",
+    "username": "$GITBRIDGE_USERNAME",
+    "password": "$GITBRIDGE_PASSWORD",
+    "postbackBaseUrl": "https://localhost",
+    "serviceName": "Overleaf",
+    "oauth2": {
+        "oauth2ClientID": "$GITBRIDGE_OAUTH2_CLIENT_ID",
+        "oauth2ClientSecret": "$GITBRIDGE_OAUTH2_CLIENT_SECRET",
+        "oauth2Server": "https://localhost"
+    },
+    "repoStore": {
+        "maxFileNum": 2000,
+        "maxFileSize": 52428800
+    },
+    "swapStore": {
+        "type": "s3",
+        "awsAccessKey": "asdf",
+        "awsSecret": "asdf",
+        "s3BucketName": "com.overleaf.testbucket",
+        "awsRegion": "us-east-1"
+    },
+    "swapJob": {
+        "minProjects": 50,
+        "lowGiB": 128,
+        "highGiB": 256,
+        "intervalMillis": 3600000,
+        "compressionMethod": "gzip"
+    }
+}

+ 3 - 0
services/git-bridge/start.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+envsubst < /envsubst_template.json > /conf/runtime.json
+java -jar /git-bridge.jar /conf/runtime.json