Skip to content

Procfile: run nginx via docker#1376

Open
alxndrsn wants to merge 18 commits intogetodk:masterfrom
alxndrsn:nginx-docker-2025
Open

Procfile: run nginx via docker#1376
alxndrsn wants to merge 18 commits intogetodk:masterfrom
alxndrsn:nginx-docker-2025

Conversation

@alxndrsn
Copy link
Contributor

@alxndrsn alxndrsn commented Oct 21, 2025

Work done to get this project working on a new system.

This should help:

  • standardise the nginx version running on different dev machines
  • simplify dev environment setup
  • standardise behaviour between central's deployed docker, and dev machines
  • streamline testing frontend-related changes to nginx config

What has been done to verify that this works as intended?

Tested locally - this is just for dev.

Why is this the best possible solution? Were any other approaches considered?

This subject was discussed previously at #1035.

The final suggestion there was to maintain the default behaviour of requiring devs to install and maintain their own nginx installations.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

No change - this is dev-only.

Does this change require updates to user documentation? If so, please file an issue here and include the link below.

No. But dev documentation has been updated.

Before submitting this PR, please make sure you have:

  • run npm run test and npm run lint and confirmed all checks still pass OR confirm CircleCI build passes
  • verified that any code or assets from external sources are properly credited in comments or that everything is internally sourced

@alxndrsn alxndrsn force-pushed the nginx-docker-2025 branch 2 times, most recently from 74d0c2a to 5199897 Compare October 21, 2025 09:16
This should help:

* standardise the nginx version running on different dev machines
* simplify dev environment setup
@brontolosone
Copy link
Contributor

I want the option to continue running my own nginx / postgres etc...

Probably the easiest way to go about it is to simply add an nginx-in-docker target line in the Procfile rather than replacing the existing nginx line, and adjust the package.json/scripts ?

@alxndrsn
Copy link
Contributor Author

I want the option to continue running my own nginx / postgres etc...

👍 if you still have an option to achieve this, would you object to nginx-in-docker being the default?

If so, what would your preference be for choosing non-docker nginx?

Some approaches I can think of:

  • different npm script, e.g. npm run dev-no-docker
  • env var, e.g. NO_DOCKER=1 npm run dev
  • Procfile first tries to start with local nginx, and then tries via docker

@brontolosone
Copy link
Contributor

I want the option to continue running my own nginx / postgres etc...

👍 if you still have an option to achieve this, would you object to nginx-in-docker being the default?

I will sigh in resignation for the fact that "run some software on a computer", which I take for a solved problem, nowadays is hardly ever mentioned without the word "docker" somewhere.

If so, what would your preference be for choosing non-docker nginx?

Some approaches I can think of:

* different `npm` script, e.g. `npm run dev-no-docker`

* env var, e.g. `NO_DOCKER=1 npm run dev`

* `Procfile` first tries to start with local nginx, and then tries via docker

They're listed in order of descending desirability for me!

@alxndrsn alxndrsn marked this pull request as ready for review October 21, 2025 11:30
@matthew-white
Copy link
Member

I don't think my thoughts have changed that much about this since #1035. I'd personally prefer just to run Frontend locally without Docker, but I can see how it'd be helpful to support Docker as well. 👍 If it's feasible to support both setups, that sounds great to me.

One question I have is whether the Docker setup plays well with Vite HMR. If you change Frontend code while using Docker, does it immediately update in the browser? If so, making Docker the default sounds reasonable to me. I think HMR should be on by default, so if the Docker setup doesn't play well with HMR, I think Docker should get its own command (npm run dev:docker?). Note that right now, there's a difference between npm run dev, which uses HMR, and npm run dev:build, which doesn't use HMR and is more similar to the development setup pre-Vite.

They're listed in order of descending desirability for me!

+1

Thanks for working on this, @alxndrsn!

alxndrsn pushed a commit to alxndrsn/odk-central-frontend that referenced this pull request Oct 22, 2025
* tidy up the repo a little
* prepare for potential changes to the config in e.g. getodk#1376
@alxndrsn
Copy link
Contributor Author

alxndrsn commented Dec 9, 2025

If you change Frontend code while using Docker, does it immediately update in the browser?

Yes 👍

alxndrsn added a commit that referenced this pull request Jan 13, 2026
* tidy up the repo a little
* prepare for potential changes to the config in e.g. #1376
@alxndrsn
Copy link
Contributor Author

I've had another go at this, and got close to zero changes with the nginx config, and supporting both with/without docker via:

npm run dev
npm run dev-no-docker

I haven't tested npm run dev-no-docker. Hopefully the -g "daemon off;" switch works - when included in the config file it breaks nginx startup with:

nginx: [emerg] "daemon" directive is duplicate in /etc/nginx/nginx.conf:14

Copy link
Member

@matthew-white matthew-white left a comment

Choose a reason for hiding this comment

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

I've had another go at this, and got close to zero changes with the nginx config, and supporting both with/without docker

Excellent news, that sounds perfect to me.

I have a few small questions, but this approach is looking great to me.

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