Merge pull request #3911 from matrix-org/jcgruenhage/docker-support-python3

make python 3 work in the docker container
This commit is contained in:
Richard van der Hoff 2018-09-25 15:18:09 +01:00 committed by GitHub
commit f65163627f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

1
changelog.d/3911.misc Normal file
View file

@ -0,0 +1 @@
Fix the docker image building on python 3

View file

@ -1,4 +1,5 @@
FROM docker.io/python:2-alpine3.8 ARG PYTHON_VERSION=2
FROM docker.io/python:${PYTHON_VERSION}-alpine3.8
COPY . /synapse COPY . /synapse

View file

@ -5,6 +5,7 @@ import os
import sys import sys
import subprocess import subprocess
import glob import glob
import codecs
# Utility functions # Utility functions
convert = lambda src, dst, environ: open(dst, "w").write(jinja2.Template(open(src).read()).render(**environ)) convert = lambda src, dst, environ: open(dst, "w").write(jinja2.Template(open(src).read()).render(**environ))
@ -23,7 +24,7 @@ def generate_secrets(environ, secrets):
with open(filename) as handle: value = handle.read() with open(filename) as handle: value = handle.read()
else: else:
print("Generating a random secret for {}".format(name)) print("Generating a random secret for {}".format(name))
value = os.urandom(32).encode("hex") value = codecs.encode(os.urandom(32), "hex").decode()
with open(filename, "w") as handle: handle.write(value) with open(filename, "w") as handle: handle.write(value)
environ[secret] = value environ[secret] = value