summary refs log tree commit diff
path: root/docker/start.py
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2019-06-27 11:17:44 +0100
committerGitHub <noreply@github.com>2019-06-27 11:17:44 +0100
commitb1b8a24b63c6c8b2076a3070c26e5ee2e8d6edb7 (patch)
treee89fe41b728fa578c8a0bb94bcd0ea1b9accd9c2 /docker/start.py
parentMerge pull request #5562 from matrix-org/rav/docker/no-generate-keys (diff)
parentchangelog (diff)
downloadsynapse-b1b8a24b63c6c8b2076a3070c26e5ee2e8d6edb7.tar.xz
Merge pull request #5563 from matrix-org/rav/docker/data_dir
Docker image: add support for SYNAPSE_DATA_DIR parameter
Diffstat (limited to 'docker/start.py')
-rwxr-xr-xdocker/start.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/docker/start.py b/docker/start.py
index 59527a5883..1e6acb464c 100755
--- a/docker/start.py
+++ b/docker/start.py
@@ -122,11 +122,12 @@ def generate_config_from_template(environ, ownership):
     return config_path
 
 
-def run_generate_config(environ):
+def run_generate_config(environ, ownership):
     """Run synapse with a --generate-config param to generate a template config file
 
     Args:
-        environ (dict): environment dictionary
+        environ (dict): env var dict
+        ownership (str): "userid:groupid" arg for chmod
 
     Never returns.
     """
@@ -134,6 +135,11 @@ def run_generate_config(environ):
         if v not in environ:
             error("Environment variable '%s' is mandatory in `generate` mode." % (v,))
 
+    data_dir = environ.get("SYNAPSE_DATA_DIR", "/data")
+
+    # make sure that synapse has perms to write to the data dir.
+    subprocess.check_output(["chown", ownership, data_dir])
+
     args = [
         "python",
         "-m",
@@ -144,8 +150,11 @@ def run_generate_config(environ):
         environ["SYNAPSE_REPORT_STATS"],
         "--config-path",
         environ["SYNAPSE_CONFIG_PATH"],
+        "--data-directory",
+        data_dir,
         "--generate-config",
     ]
+    # log("running %s" % (args, ))
     os.execv("/usr/local/bin/python", args)
 
 
@@ -153,9 +162,9 @@ def main(args, environ):
     mode = args[1] if len(args) > 1 else None
     ownership = "{}:{}".format(environ.get("UID", 991), environ.get("GID", 991))
 
-    # In generate mode, generate a configuration, missing keys, then exit
+    # In generate mode, generate a configuration and missing keys, then exit
     if mode == "generate":
-        return run_generate_config(environ)
+        return run_generate_config(environ, ownership)
 
     # In normal mode, generate missing keys if any, then run synapse
     if "SYNAPSE_CONFIG_PATH" in environ: