mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Configure from env vars at run time
In both local developent, and production. Also, vendor the `envsubst` binary from https://github.com/a8m/envsubst, as it supports default values, which the gnu envsubst (from gettext-base) does not.
This commit is contained in:
parent
f1c9d6108e
commit
b47f21a44e
7 changed files with 49 additions and 32 deletions
|
@ -6,3 +6,4 @@
|
|||
!/pom.xml
|
||||
!/Makefile
|
||||
!/LICENSE
|
||||
!/vendor
|
||||
|
|
3
services/git-bridge/.gitignore
vendored
3
services/git-bridge/.gitignore
vendored
|
@ -48,3 +48,6 @@ com_crashlytics_export_strings.xml
|
|||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Local configuration files
|
||||
conf/runtime.json
|
||||
|
|
|
@ -2,16 +2,20 @@
|
|||
|
||||
FROM maven:3-jdk-8 as base
|
||||
|
||||
RUN apt-get update && apt-get install -y make \
|
||||
RUN apt-get update && apt-get install -y make git \
|
||||
&& rm -rf /var/lib/apt/lists
|
||||
|
||||
COPY vendor/envsubst /opt/envsubst
|
||||
RUN chmod +x /opt/envsubst
|
||||
|
||||
RUN useradd --create-home node
|
||||
|
||||
FROM base as builder
|
||||
|
||||
COPY . /app
|
||||
|
||||
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.
|
||||
|
@ -21,15 +25,16 @@ RUN make package \
|
|||
|
||||
FROM openjdk:8-jre
|
||||
|
||||
RUN apt-get update && apt-get install -y git gettext-base\
|
||||
RUN apt-get update && apt-get install -y git \
|
||||
&& rm -rf /var/lib/apt/lists
|
||||
|
||||
RUN useradd --create-home node
|
||||
|
||||
CMD ["/start.sh"]
|
||||
|
||||
COPY --from=builder /git-bridge.jar /
|
||||
|
||||
COPY vendor/envsubst /opt/envsubst
|
||||
RUN chmod +x /opt/envsubst
|
||||
|
||||
COPY conf/envsubst_template.json envsubst_template.json
|
||||
COPY start.sh start.sh
|
||||
|
||||
|
@ -37,3 +42,5 @@ RUN mkdir conf
|
|||
RUN chown node:node conf
|
||||
|
||||
USER node
|
||||
|
||||
ENTRYPOINT ["/start.sh"]
|
||||
|
|
|
@ -2,8 +2,14 @@
|
|||
|
||||
MVN_OPTS := "--no-transfer-progress"
|
||||
|
||||
run: package
|
||||
java -jar target/writelatex-git-bridge-1.0-SNAPSHOT-jar-with-dependencies.jar conf/local.json
|
||||
runtime-conf:
|
||||
/opt/envsubst < conf/envsubst_template.json > conf/runtime.json
|
||||
|
||||
|
||||
run: package runtime-conf
|
||||
java -jar \
|
||||
target/writelatex-git-bridge-1.0-SNAPSHOT-jar-with-dependencies.jar \
|
||||
conf/runtime.json
|
||||
|
||||
|
||||
build:
|
||||
|
@ -22,4 +28,4 @@ package: clean
|
|||
mvn $(MVN_OPTS) package -DskipTests
|
||||
|
||||
|
||||
.PHONY: run package build clean test
|
||||
.PHONY: run package build clean test runtime-conf
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
{
|
||||
"port": 8080,
|
||||
"rootGitDirectory": "/tmp/wlgb",
|
||||
"apiBaseUrl": "https://localhost/api/v0",
|
||||
"username": "$GITBRIDGE_USERNAME",
|
||||
"password": "$GITBRIDGE_PASSWORD",
|
||||
"postbackBaseUrl": "https://localhost",
|
||||
"serviceName": "Overleaf",
|
||||
"port": ${GIT_BRIDGE_PORT:-8000},
|
||||
"rootGitDirectory": "${GIT_BRIDGE_ROOT_DIR:-/tmp/wlgb}",
|
||||
"apiBaseUrl": "${GIT_BRIDGE_API_BASE_URL:-https://localhost/api/v0}",
|
||||
"username": "${GIT_BRIDGE_USERNAME}",
|
||||
"password": "${GIT_BRIDGE_PASSWORD}",
|
||||
"postbackBaseUrl": "${GIT_BRIDGE_POSTBACK_BASE_URL:-https://localhost}",
|
||||
"serviceName": "${GIT_BRIDGE_SERVICE_NAME:-Overleaf}",
|
||||
"oauth2": {
|
||||
"oauth2ClientID": "$GITBRIDGE_OAUTH2_CLIENT_ID",
|
||||
"oauth2ClientSecret": "$GITBRIDGE_OAUTH2_CLIENT_SECRET",
|
||||
"oauth2Server": "https://localhost"
|
||||
"oauth2ClientID": "${GITBRIDGE_OAUTH2_CLIENT_ID}",
|
||||
"oauth2ClientSecret": "${GITBRIDGE_OAUTH2_CLIENT_SECRET}",
|
||||
"oauth2Server": "${GIT_BRIDGE_OAUTH2_SERVER:-https://localhost}"
|
||||
},
|
||||
"repoStore": {
|
||||
"maxFileNum": 2000,
|
||||
"maxFileSize": 52428800
|
||||
"maxFileNum": ${GIT_BRIDGE_REPOSTORE_MAX_FILE_NUM:-2000},
|
||||
"maxFileSize": ${GIT_BRIDGE_REPOSTORE_MAX_FILE_SIZE:-52428800}
|
||||
},
|
||||
"swapStore": {
|
||||
"type": "s3",
|
||||
"awsAccessKey": "asdf",
|
||||
"awsSecret": "asdf",
|
||||
"s3BucketName": "com.overleaf.testbucket",
|
||||
"awsRegion": "us-east-1"
|
||||
"type": "${GIT_BRIDGE_SWAPSTORE_TYPE:-noop}",
|
||||
"awsAccessKey": "${GIT_BRIDGE_SWAPSTORE_AWS_ACCESS_KEY}",
|
||||
"awsSecret": "${GIT_BRIDGE_SWAPSTORE_AWS_ACCESS_KEY}",
|
||||
"s3BucketName": "${GIT_BRIDGE_SWAPSTORE_S3_BUCKET_NAME}",
|
||||
"awsRegion": "${GIT_BRIDGE_SWAPSTORE_AWS_REGION:-us-east-1}"
|
||||
},
|
||||
"swapJob": {
|
||||
"minProjects": 50,
|
||||
"lowGiB": 128,
|
||||
"highGiB": 256,
|
||||
"intervalMillis": 3600000,
|
||||
"compressionMethod": "gzip"
|
||||
"minProjects": ${GIT_BRIDGE_SWAPJOB_MIN_PROJECTS:-50},
|
||||
"lowGiB": ${GIT_BRIDGE_SWAPJOB_LOW_GIB:-128},
|
||||
"highGiB": ${GIT_BRIDGE_SWAPJOB_HIGH_GIB:-256},
|
||||
"intervalMillis": ${GIT_BRIDGE_SWAPJOB_INTERVAL_MILLIS:-3600000},
|
||||
"compressionMethod": "${GIT_BRIDGE_SWAPJOB_COMPRESSION_METHOD:-gzip}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/bash
|
||||
envsubst < /envsubst_template.json > /conf/runtime.json
|
||||
java -jar /git-bridge.jar /conf/runtime.json
|
||||
/opt/envsubst < /envsubst_template.json > /conf/runtime.json
|
||||
exec java -jar /git-bridge.jar /conf/runtime.json
|
||||
|
|
BIN
services/git-bridge/vendor/envsubst
vendored
Executable file
BIN
services/git-bridge/vendor/envsubst
vendored
Executable file
Binary file not shown.
Loading…
Reference in a new issue