buildpacks icon indicating copy to clipboard operation
buildpacks copied to clipboard

Add a static site buildpack, useful for react and vue apps, can be nginx or other web server

Open yairyairyair opened this issue 2 years ago • 6 comments

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] If this feature is related to an existing issue, please provide a link to that as well

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

It can be detected via if has folder build or dist, if yes then should add nginx with SPA/pushstate config Seems useful because frontend static apps currently are hard to run in google buildpacks

yairyairyair avatar May 30 '23 17:05 yairyairyair

Also there is already an nginx buildpack as utils.

And the detect script can also detect an nginx.conf and apply it instead for further customization

yairyairyair avatar May 30 '23 18:05 yairyairyair

I'm assuming that you're building your react/vue apps in CI/CD pipeline, and you just want to deploy the compiled files using a static site buildpack?

jama22 avatar May 30 '23 20:05 jama22

I have a backend node js app, I run pack build with google buildpack builder and it obviously works.

I want to run the same command for the frontend react app and that it will still work (npm run build products dist folder so should be able to serve it)

yairyairyair avatar May 30 '23 21:05 yairyairyair

There is no CI CD, Basically, The pack build command runs npm run build by default as it should, and then runs npm start. It should in my opinion check via some env param if it is an SPA frontend and if so then instead of npm start should serve the dist/build folder

yairyairyair avatar May 30 '23 21:05 yairyairyair

Ah okay, that makes a lot of sense. We've been seeing this kind of use case/request a lot. It could similarly help with easily serving markdown-generated HTML sites (e.g. Hugo, Jekyll), or pre-compiled applications (e.g. Go executables, Java, Java native images, etc.)

jama22 avatar Jun 01 '23 19:06 jama22

Yes indeed could be useful, will this issue be in like a roadmap or something? I would have tried coding it yet have no knowledge about buildpacks

yairyairyair avatar Jun 02 '23 13:06 yairyairyair