1
0

Remove MoveToComplement.Dockerfile

Also added some debug logging in order to try and figure out why the
main homeserver config file isn't getting generated by start.py
This commit is contained in:
Andrew Morgan
2021-01-06 23:54:31 -05:00
parent 1acb2d9ee1
commit ce591bf75b
3 changed files with 11 additions and 40 deletions

View File

@@ -1,35 +0,0 @@
# This dockerfile builds on top of Dockerfile-worker and includes a built-in postgres instance.
# It is intended to be used for Complement testing
FROM matrixdotorg/synapse:workers
# Install postgres
RUN apt-get update
RUN apt-get install -y postgres
# Create required databases in postgres
# Create a user without a password
RUN sudo -u postgres createuser -w synapse_user
# Then set their password
RUN sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'somesecret';"
# Create the synapse database
RUN sudo -u postgres psql -c "CREATE DATABASE synapse \
ENCODING 'UTF8' \
LC_COLLATE='C' \
LC_CTYPE='C' \
template=template0 \
OWNER synapse_user;"
# Modify Synapse's database config to point to the local postgres
COPY ./docker/synapse_use_local_postgres.py /synapse_use_local_postgres.py
RUN /synapse_use_local_postgres.py
VOLUME ["/data"]
EXPOSE 8008/tcp 8009/tcp 8448/tcp
# Start supervisord
CMD ["/usr/bin/supervisord"]

View File

@@ -144,7 +144,8 @@ def generate_base_homeserver_config():
"""
# start.py already does this for us, so just call that.
# note that this script is copied in in the official, monolith dockerfile
subprocess.check_output(["/usr/local/bin/python", "/start.py", "migrate_config"])
output = subprocess.check_output(["/usr/local/bin/python", "/start.py", "generate"], shell=True)
print("Got output:", output)
def generate_worker_files(environ, config_path: str, data_dir: str):
@@ -302,11 +303,12 @@ stderr_logfile_maxbytes=0""".format_map(worker_config)
worker_port += 1
# Write out the config files
# Write out the config files. We use append mode for each in case the
# files may have already been written to by others.
# Shared homeserver config
print(homeserver_config)
with open("/conf/workers/shared.yaml", "w") as f:
with open("/conf/workers/shared.yaml", "a") as f:
f.write(homeserver_config)
# Nginx config
@@ -314,7 +316,7 @@ stderr_logfile_maxbytes=0""".format_map(worker_config)
print(nginx_config_template_header)
print(nginx_config_body)
print(nginx_config_template_end)
with open("/etc/nginx/conf.d/matrix-synapse.conf", "w") as f:
with open("/etc/nginx/conf.d/matrix-synapse.conf", "a") as f:
f.write(nginx_config_template_header)
f.write(nginx_config_body)
f.write(nginx_config_template_end)
@@ -322,7 +324,7 @@ stderr_logfile_maxbytes=0""".format_map(worker_config)
# Supervisord config
print()
print(supervisord_config)
with open("/etc/supervisor/conf.d/supervisord.conf", "w") as f:
with open("/etc/supervisor/conf.d/supervisord.conf", "a") as f:
f.write(supervisord_config)
# Ensure the logging directory exists

View File

@@ -134,6 +134,7 @@ def run_generate_config(environ, ownership):
Never returns.
"""
print("running generate config")
for v in ("SYNAPSE_SERVER_NAME", "SYNAPSE_REPORT_STATS"):
if v not in environ:
error("Environment variable '%s' is mandatory in `generate` mode." % (v,))
@@ -149,6 +150,8 @@ def run_generate_config(environ, ownership):
log("Creating log config %s" % (log_config_file,))
convert("/conf/log.config", log_config_file, environ)
print("Generating config at", config_path, "Config dir:", config_dir)
args = [
"python",
"-m",
@@ -178,6 +181,7 @@ def run_generate_config(environ, ownership):
os.execv("/usr/local/bin/python", args)
def main(args, environ):
print("bla")
mode = args[1] if len(args) > 1 else "run"
desired_uid = int(environ.get("UID", "991"))
desired_gid = int(environ.get("GID", "991"))