Skip to content

Conversation

alexcottner
Copy link
Contributor

No description provided.

@alexcottner alexcottner force-pushed the version-env-var branch 2 times, most recently from 5671f51 to e318072 Compare July 11, 2025 15:11
:rtype: dict or None
"""
version_json = os.path.join(root, "version.json")
version_env_var = os.getenv("DOCKERFLOW_VERSION")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add this additional source of information instead of using the version.json file?

Copy link
Contributor Author

@alexcottner alexcottner Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We adjusted the remote-settings release process to re-tag the existing image instead of building a fresh one (link). This reduces our release times and allows us to use the exact same image that's been working great already in dev/stage.

But, the version file doesn't then get rebuilt so our version endpoint is incorrect. My best ideas to solve this were:

  1. Allow for an optional version parameter to be sent (this PR basically)
  2. Update and mount a configmap for the version.json file on deploy

This felt a little easier to me but I'm open to option 2.

Copy link
Collaborator

@willkg willkg Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think sliding the version in outside of the version.json file doesn't make sense and breaks the contract of version.json.

I think it'd be better to have a short Dockerfile template, expand the template with the image details of the stage image you're using, and then COPY the updated version.json file.

You should talk with @grahamalama and see if that's something we can put in deploy-actions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Yeah that's another option and is pretty simple to implement

Comment on lines 24 to 26
def test_env_var_override(tmpdir):
content = {"spam": "eggs"}
mock.patch.dict(os.environ, { "DOCKERFLOW_VERSION": "foo"})
version_json = tmpdir.join("version.json")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library uses pytest, so you should use its monkeypatching:

https://docs.pytest.org/en/stable/how-to/monkeypatch.html

Suggested change
def test_env_var_override(tmpdir):
content = {"spam": "eggs"}
mock.patch.dict(os.environ, { "DOCKERFLOW_VERSION": "foo"})
version_json = tmpdir.join("version.json")
def test_env_var_override(tmpdir, monkeypatch):
content = {"spam": "eggs"}
monkeypatch.setenv("DOCKERFLOW_VERSION", "foo")
version_json = tmpdir.join("version.json")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants