ericclemmons/polydev

per-branch deployments

ericclemmons opened this issue · 1 comments

Here's a crazy idea:

  1. /routes/branch/:name
  2. module.exports = async () => ...
  3. Clone that branch into that a tmp folder.
  4. return require(tmp)

In theory, this could work!

There would need to be a ~5 minute or ~10 minute timer to kill lambdas, but that's easy.

This seems necessary, mainly because of the need to rewrite URLs:

https://github.com/chimurai/http-proxy-middleware

With that said, the support for package.json could be an option.

  • polydev is the one starting processes, not the route. So the route doesn't know what the PORT is. (Or does it!?)
  • The route needs to return an async route to do the install (maybe not with execSync, but we need req.params).
  • The problem with PORT is that the route is already listening on that port, so starting a new server needs guessing another port. (1${PORT}? )

Here's a potential solution:

module.exports = (req, res) => {
  const { branch } req.params

  if (!started) {
    execSync(...allTheThings)
    require('./path/to/branch/server') // PORT should be set!
  }

  return httpProxyMiddleware(...)
}