Skip to content

Serve frontend from same server as the backend #106

@batpad

Description

@batpad

As we move the application into the Mozambique IT environment, we should ideally serve everything from the server we setup there, including the frontend. This will also give us more flexibility in how we handle dynamically rebuilding the frontend when data changes, to handle data updates that are ideally baked into the frontend build.

Roughly I'd do this in two phases:

Phase 1: Serve frontend via nginx on server

  • Add a folder on the server like /var/www/moz-frontend
  • Pull and build the frontend code
  • Add nginx config to server the frontend dist folder on a separate subdomain
  • Create a webhook so that pushes to main on the frontend trigger pulling latest code and rebuilding on the server to serve an updated frontend.

At this point, we'd have the frontend being served from the server, and we will have the ability to trigger a rebuild by pushing a commit to main.

Phase 2: Auto re-build frontend in response to data changes

As the frontend "bakes in" some data from the backend as part of the build, we ideally also want a way to have the frontend build be re-triggered when something in the backend data / data models change. For this, we would want roughly:

  • Create a celery task to handle rebuilding the frontend
  • Trigger the celery task whenever a data model / scenario is added or edited

Since automatically triggering the build in response to data changes could get a little tricky, the other option would be to have something like a button on the Admin that says "Publish Frontend" which triggers the celery task via an explicit user action in the Admin.

I need to think about this a bit. I think I can go ahead with Phase 1 described above and just get the server serving the frontend with the same nginx setup, may need some help thinking through Phase 2 to automate re-builds.

cc @hanbyul-here @willemarcel @LanesGood

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions