diff --git a/Dockerfile b/Dockerfile index 258022e8a457..3450709b7548 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM python:3.11-slim-bookworm AS olympia -ENV BUILD_INFO=/build-info +ENV BUILD_INFO=/build-info.json # Set shell to bash with logs and errors for build SHELL ["/bin/bash", "-xue", "-c"] @@ -33,11 +33,13 @@ ARG DOCKER_TARGET # Create the build file hard coding build variables to the image RUN < ${BUILD_INFO} -commit="${DOCKER_COMMIT}" -version="${DOCKER_VERSION}" -build="${DOCKER_BUILD}" -target="${DOCKER_TARGET}" -source="https://github.com/mozilla/addons-server" +{ + "commit": "${DOCKER_COMMIT}", + "version": "${DOCKER_VERSION}", + "build": "${DOCKER_BUILD}", + "target": "${DOCKER_TARGET}", + "source": "https://github.com/mozilla/addons-server" +} INNEREOF # Set permissions to make the file readable by all but only writable by root chmod 644 ${BUILD_INFO} diff --git a/src/olympia/core/tests/test_utils.py b/src/olympia/core/tests/test_utils.py index e427bc7a3f67..3a850dd26620 100644 --- a/src/olympia/core/tests/test_utils.py +++ b/src/olympia/core/tests/test_utils.py @@ -30,17 +30,13 @@ def tearDown(self): shutil.rmtree(self.tmp_dir) def with_build_info(self, **kwargs): - data = '\n'.join( - f'{key}="{value}"' for key, value in {**default_version, **kwargs}.items() - ) + data = json.dumps({**default_version, **kwargs}) with open(self.build_info_path, 'w') as f: f.write(data) - f.close() def with_pkg_json(self, data): with open(self.pkg_json_path, 'w') as f: f.write(json.dumps(data)) - f.close() def test_get_version_json_defaults(self): result = get_version_json(build_info_path=self.build_info_path) diff --git a/src/olympia/core/utils.py b/src/olympia/core/utils.py index 987487377893..c6ed01bf7d68 100644 --- a/src/olympia/core/utils.py +++ b/src/olympia/core/utils.py @@ -24,10 +24,8 @@ def get_version_json( # be overridden at runtime. if os.path.exists(build_info_path): with open(build_info_path) as f: - for line in f: - key, value = line.strip().split('=', 1) - if value.startswith('"') and value.endswith('"'): - value = value[1:-1] + data = json.loads(f.read()) + for key, value in data.items(): contents[key] = value py_info = sys.version_info