fix(#10754): set NODE_ENV to production in Docker images#10758
fix(#10754): set NODE_ENV to production in Docker images#10758jkuester merged 6 commits intomedic:masterfrom
Conversation
|
After testing the inclusion of NODE_ENV=production in the base Dockerfiles, I’ve confirmed that this breaks the authentication flow in the Webdriver and Integration CI suites. While the unit tests passed, the integration environment relies on HTTP. Forcing the Secure; flag causes browsers to reject session cookies over these unencrypted connections. I have reverted the Dockerfile changes to restore a green CI and suggest we move this configuration to the production orchestration layer instead. |
|
Hi @vikrantwiz02 - this PR is looking good! While we wait for Sugat's PR to wrap up so we can rebase, I wanted to test locally. My steps were:
My last step shows this, note there's now Given we should default to Thanks! |
|
Hi @mrjones-plip, thanks again for the detailed feedback! I’ve done some local testing to investigate the environment discrepancy:
Based on these results, it appears the images are now secure by default for production while remaining fully compatible with our local tools!" |
|
Hi @vikrantwiz02 - can you please follow my steps and verify you get a thanks! |
|
Thanks for the direction, @mrjones-plip. I'll follow those exact steps using the docker-helper and check the compose files in ~/.medic/cht-docker/ to see if I get the Secure; flag in the curl output. I'll get back to you with the results shortly. Thanks! |
|
@mrjones-plip I followed the verification steps for a CHT 5.0.0 instance. Although the .env file from the cht-docker helper was not being correctly generated/found in my local environment, I was able to successfully verify the results by manually running the compose files with the fix image (using localhost for the curl check).
|
|
Thanks for the steps @vikrantwiz02 ! I see in step one I hadn't switched branches in your repo from Now that I'm on the correct branch, and I've rebuilt the images, I do indeed see I wanted to point out some discrepancies in your last comment's
When using an AI or not, you're responsible for all of your code and comments. Please try not waste teammates time and always double check the final work. These are obvious errors when you compare my steps to yours. By not checking the correct cookie, the one cited in the parent ticket, we could be testing the wrong outcome and not actually fix the main issue. Otherwise, I have some unhappy path testing I should do as well as comparing to the parallel PR from Sugat, so gimme a sec before a final approval. |
|
Sorry about that, @mrjones-plip. I definitely got a bit ahead of myself. I was having a hard time getting a successful login to work on my local and i got diverted due to this. Thanks, this has been a great learning experience for me. |
what were the issues you were having? I saw you were not running docker helper - did you have troubles running this? |
|
also - there's no need to quote the entire contents of my prior comment in your response - GH shows you the prior comment right above ;) |
|
Also also - I'm re-running the CI as a bunch of jobs failed - when that completes, if there's still errors, can you look into if they're endemic to this branch? |
ec7bb19 to
f1be725
Compare
|
Sir @mrjones-plip, the Dockerfile updates and compose overrides are pushed! Unit, Webdriver E2E, and Compose integration tests are all green now. The only remaining failures are the two k3d suites. Since k3d uses Helm, it naturally ignores the compose overrides, boots in production mode, and fails the auth checks. (Note: I tried injecting NODE_ENV: development into integration-k3d-values.yaml.template, but it caused the cluster to timeout). What is the preferred way to pass NODE_ENV=development to the k3d test runners so we can get this fully green? |
f1be725 to
3e0cf25
Compare
Check out the parallel PR to see how they're doing it. It looks like they enhance the built helm template to accept a env var being sure to set a sane default. Then in integration test they set env var to in the values yaml file. |
45f98f8 to
f4a297b
Compare
|
@vikrantwiz02 - if possible, please try to avoid force pushes during a PR review. It makes for broken links - for example I get this in my GH email notification: View it on GitHub |
f4a297b to
35aa06c
Compare
|
@mrjones-plip understood! My apologies for breaking the notification links. I was amending the commit to keep the PR history down to a single commit, but I will definitely stick to adding regular commits for updates going forward during reviews. Also, just a heads-up that the Helm template updates to pass NODE_ENV=development to the k3d test runners are now pushed! Let me know if the implementation looks correct to you. |
|
All PRs do a squash commit to I'll have a look at your helm template changes! |
|
Hi @mrjones-plip, |
|
Hi @mrjones-plip, I re-ran the failing jobs separately on my fork, and both passed successfully It looks like those failures may have been transient. Let me know if you’d like me to investigate further or if re-running CI on this PR would be sufficient. Thanks! |
|
thanks for re-running the tests in your branch @vikrantwiz02 ! glad to see they all passed. now that Sugat's PR is merged, there's some conflicts. Please resolve those. Thanks! |
mrjones-plip
left a comment
There was a problem hiding this comment.
Per above - please resolve conflicts and see if there's any changes from the other PR we need to incorporate in our PR
|
Hi @mrjones-plip, the conflicts are all resolved! I made sure to incorporate the new LOG_LEVEL configurations from Sugat's PR alongside the NODE_ENV updates, so both sets of changes are fully intact. The CI checks are running on the new merge commit now. Let me know if everything looks good to you! |
|
Thanks @vikrantwiz02 ! I've merged latest in from |
|
@jkuester - I'm wrapping up my testing and I think we're good to go here. One thing I'm not seeing is a test to ensure |
mrjones-plip
left a comment
There was a problem hiding this comment.
Thanks so much @vikrantwiz02 !
Waiting for final approval to see if we should add a test.
|
Well, in general I would say, yes, we have already regressed on this once, so would be good to have a test for it. However, unless I am missing something, our tests run with If we can come up with a simple way to test it, then lets go for it, but it seems like it could be a big hassle. (And in that case I think it would be best to just ship as it.) 🤷 |
|
....and I accidentally hit the merge button. 😱 Well, I guess if someone has an idea of how to test this we can add it in a different PR. 🤦 Otherwise LGTM! 😅 |
|
😂😄 Thanks for the accidental merge. Thank you both for the help and the review, @mrjones-plip and @jkuester! Makes total sense about the development environment blocking the test. I'm glad the code looks good to go. Shipping to the next issue! 😁 |
|
hah! thanks @jkuester ! |



Description:
This PR ensures that Secure; cookies are enabled by default in production while maintaining a functional, non-SSL development environment for integration and E2E testing.
Fixes #10754
Problem
The logic in api/src/services/cookie.js relies on NODE_ENV=production to enable the Secure; flag. Since this variable was missing from the Docker images, cookies were being sent without the flag even in production environments.
Changes:
Testing:
Code review checklist
can_view_old_navigationpermission to see the old design. Test it has appropriate design for RTL languages.License
The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.