Skip to content

Reload app settings on .env file change for local deployment#223

Merged
igorbenav merged 2 commits intobenavlabs:stagingfrom
rragundez:envs-local
Nov 21, 2025
Merged

Reload app settings on .env file change for local deployment#223
igorbenav merged 2 commits intobenavlabs:stagingfrom
rragundez:envs-local

Conversation

@rragundez
Copy link
Copy Markdown
Contributor

@rragundez rragundez commented Nov 19, 2025

IMPORTANT: PR #222 has to be merged first.

At the moment there is a mixture of getting settings from environment variables and from an .env file. This is confusing and can lead to cumbersome bugs. This PR addresses the problem only for the local deployment (prod and staging will come later) where it makes it clear that settings will only be taken from the .env file (via environment variables) and removes the setting of environment variables to the runtime via the docker compose definition.
While doing that then it is also possible to enable reloading of the application based on changes to the .env file, which is quite useful for development. At the moment the app only reload when py files change.
It also removed the command in the docker compose definition and simplifies the responsibility of running the command by giving it solely to the Dockerfile (at the moment it seems to be and be promoted via the comments to change the command in either dockerfile or docker compose which is confusing for a user).

@igorbenav
Copy link
Copy Markdown
Collaborator

@LucasQR

@igorbenav igorbenav requested a review from LucasQR November 19, 2025 17:39
@rragundez rragundez changed the title [WIP] Reload settings on .env file change for local deployment [WIP] Reload app settings on .env file change for local deployment Nov 19, 2025
Copy link
Copy Markdown
Collaborator

@LucasQR LucasQR left a comment

Choose a reason for hiding this comment

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

I'm testing this pr, and you said "While doing that then it is also possible to enable reloading of the application based on changes to the .env file, which is quite useful for development" but it doesn't seem to happen. I tried changing the ADMIN_PASSWORD on .env with the app running and then login as the admin with the new password.
It says the new admin tables are being created, says the app reloaded but the password doesn't actually change

Screenshot 2025-11-19 at 16 58 38

@rragundez rragundez reopened this Nov 20, 2025
@rragundez rragundez changed the title [WIP] Reload app settings on .env file change for local deployment Reload app settings on .env file change for local deployment Nov 20, 2025
@rragundez
Copy link
Copy Markdown
Contributor Author

rragundez commented Nov 20, 2025

@LucasQR thanks so much for checking, perhaps you forgot to add --build to the docker compose command? there is a change in the Dockerfile to watch the .env file so it needs to be rebuilt.

BTW because the commits were squashed from the other PR I had to force pushed, apologies but you will need to force pull. Hope not too much trouble.

let me know if you still see it not reloading on .env changes. Thanks again.

@rragundez
Copy link
Copy Markdown
Contributor Author

Hi @LucasQR can you have another look? Check my comment above, maybe that was the issue

@LucasQR
Copy link
Copy Markdown
Collaborator

LucasQR commented Nov 21, 2025

I'll take a look at it right now, but after I went after the reason for that error I started to think it was caused by a quirk with the logging on crudadmin. Anyway I'll check it and get back to you as soon as possible.

And just as a reminder, tag me or add me as a reviewer on any following pr on benav labs

@LucasQR
Copy link
Copy Markdown
Collaborator

LucasQR commented Nov 21, 2025

Update, it is updating the app name, description, etc(anything that doesn't involve db) . I checked further ( and may raise this as an issue after talking to @igorbenav about it) but the problem I had was caused by a silent error on crudadmin's initialize_admin_db it doesn't actually check if the tables were created by it, it only check if they exist and says they were created if they do. Since there were already admin tables there when the app restarted it says they were being created again even if they weren't.

I'd recommend putting some sort of warning or raising an error if the user tries to change db realated things on .env (aswell as updating the docs to reflect the changes made by these prs) but I'll aprove it even without

Copy link
Copy Markdown
Collaborator

@LucasQR LucasQR left a comment

Choose a reason for hiding this comment

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

works properly although i'd like a bit of documentation on this

@rragundez
Copy link
Copy Markdown
Contributor Author

Ok, thanks @LucasQR
I'll submit a bunch of PRs, I suggest getting to a stable code base after all the changes, and then reviewing all the small quirks and docs, to avoid doing duplicated work or documenting things that end up changing. I'll try to address quirks that are definitely important and same with docs.
Is that ok? So to keep moving forward

@LucasQR
Copy link
Copy Markdown
Collaborator

LucasQR commented Nov 21, 2025

Sure, the quirk i talked about is on crudadmin, not on the boilerplate so you can just keep going without fixing it. I'll review the other ones now

@igorbenav
Copy link
Copy Markdown
Collaborator

@rragundez I'll create a staging branch, let's do all the prs there then. I'll take over reviews here

@igorbenav igorbenav changed the base branch from main to staging November 21, 2025 18:48
@igorbenav igorbenav merged commit c4becf5 into benavlabs:staging Nov 21, 2025
3 checks passed
@rragundez rragundez deleted the envs-local branch November 22, 2025 05:27
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.

3 participants