Pārlūkot izejas kodu

Make conf.json and local.py customizable

Girish Ramakrishnan 6 gadi atpakaļ
vecāks
revīzija
1e0873ea02
7 mainītis faili ar 37 papildinājumiem un 8 dzēšanām
  1. 4 2
      Dockerfile
  2. 2 2
      conf.json
  3. 2 2
      conf_ldap.json
  4. 11 0
      json-merge.js
  5. 1 0
      local.py
  6. 1 0
      local_ldap.py
  7. 16 2
      start.sh

+ 4 - 2
Dockerfile

@@ -15,7 +15,9 @@ RUN curl -L https://github.com/taigaio/taiga-back/archive/3.4.5.tar.gz | tar -xz
 ## frontend (https://github.com/taigaio/taiga-front-dist/commits/stable)
 RUN curl -L https://github.com/taigaio/taiga-front-dist/archive/3.4.5-stable.tar.gz | tar -xz -C /app/code/taiga-front-dist --strip-components 1 -f -
 
-ADD build.sh nginx.conf conf.json conf_ldap.json local.py local_ldap.py start.sh /app/code/
+RUN npm install json
+
+ADD build.sh nginx.conf conf.json conf_ldap.json local.py local_ldap.py start.sh json-merge.js /app/code/
 
 ## install all deps in a python virtual env
 RUN /app/code/build.sh
@@ -23,6 +25,6 @@ RUN /app/code/build.sh
 RUN rm -rf /app/code/taiga-back/media && ln -s /app/data/media /app/code/taiga-back/media && \
     rm -rf /var/log/nginx && mkdir /run/nginx && ln -s /run/nginx /var/log/nginx && \
     rm -f /app/code/taiga-back/settings/local.py && ln -s /run/local.py /app/code/taiga-back/settings/local.py && \
-    rm -f /app/code/taiga-front-dist/dist/conf.json && ln -s /run/conf.json /app/code/taiga-front-dist/dist/conf.json
+    rm -f /app/code/taiga-front-dist/dist/conf.json && ln -s /app/data/conf.json /app/code/taiga-front-dist/dist/conf.json
 
 CMD [ "/app/code/start.sh" ]

+ 2 - 2
conf.json

@@ -1,5 +1,5 @@
 {
-    "api": "https://##APP_DOMAIN##/api/v1/",
+    "api": "",
     "eventsUrl": null,
     "eventsMaxMissedHeartbeats": 5,
     "eventsHeartbeatIntervalTime": 60000,
@@ -14,4 +14,4 @@
     "termsOfServiceUrl": null,
     "maxUploadFileSize": null,
     "contribPlugins": []
-}
+}

+ 2 - 2
conf_ldap.json

@@ -1,5 +1,5 @@
 {
-    "api": "https://##APP_DOMAIN##/api/v1/",
+    "api": "",
     "eventsUrl": null,
     "eventsMaxMissedHeartbeats": 5,
     "eventsHeartbeatIntervalTime": 60000,
@@ -15,4 +15,4 @@
     "maxUploadFileSize": null,
     "loginFormType": "ldap",
     "contribPlugins": []
-}
+}

+ 11 - 0
json-merge.js

@@ -0,0 +1,11 @@
+#!/usr/bin/env node
+
+'use strict';
+
+var fs = require('fs');
+
+var target = JSON.parse(fs.readFileSync(process.argv[2]));
+var source = JSON.parse(fs.readFileSync(process.argv[3]));
+target = Object.assign({}, source, target);
+fs.writeFileSync(process.argv[2], JSON.stringify(target, null, 4));
+

+ 1 - 0
local.py

@@ -38,3 +38,4 @@ DATABASES = {
 }
 
 WEBHOOKS_ENABLED = True
+

+ 1 - 0
local_ldap.py

@@ -20,3 +20,4 @@ LDAP_SEARCH_PROPERTY = "sAMAccountName"
 # Names of LDAP properties on user account to get email and full name
 LDAP_EMAIL_PROPERTY = "mail"
 LDAP_FULL_NAME_PROPERTY = "displayname"
+

+ 16 - 2
start.sh

@@ -25,14 +25,28 @@ if [[ -n "${LDAP_SERVER:-}" ]]; then
         /app/code/local_ldap.py >> /run/local.py
 fi
 
+# create and merge any user local.py
+if [[ -f /app/data/customlocal.py ]]; then
+    echo -e "# Place custom local.py settings in this file\n" > /app/data/customlocal.py
+fi
+
+cat /app/data/customlocal.py >> /run/local.py
+
+# create and merge any user conf.json
+if [[ ! -f /app/data/conf.json ]]; then
+    echo "{}" > /app/data/conf.json
+fi
+
 if [[ -n "${LDAP_SERVER:-}" ]]; then
     echo "=> Update conf.json with LDAP"
-    sed -e "s/##APP_DOMAIN##/${APP_DOMAIN}/" /app/code/conf_ldap.json > /run/conf.json
+    node /app/code/json-merge.js /app/data/conf.json /app/code/conf_ldap.json
 else
     echo "=> Update conf.json"
-    sed -e "s/##APP_DOMAIN##/${APP_DOMAIN}/" /app/code/conf.json > /run/conf.json
+    node /app/code/json-merge.js /app/data/conf.json /app/code/conf.json
 fi
 
+/app/code/node_modules/.bin/json -I -f /app/data/conf.json -e "this.api = '${APP_ORIGIN}/api/v1/'"
+
 echo "=> Update nginx.conf"
 sed -e "s,##APP_DOMAIN##,${APP_DOMAIN}," /app/code/nginx.conf  > /run/nginx.conf