postlight / headless-wp-starter

🔪 WordPress + React Starter Kit: Spin up a WordPress-powered React app in one step
https://archive.postlight.com/labs/wordpress-react-starter-kit
GNU General Public License v2.0
4.47k stars 651 forks source link

Now v2 deployment example? #175

Closed wickedst closed 2 years ago

wickedst commented 5 years ago

Hi there. I've been having a lot of fun with headless-wp-starter and I am nearly ready to go live with my first project based on it.

Just considering deployment options and I am really curious about Now. Does anyone have experience with deploying to the platform who could provide a sample now.json that would work with the latest commit of headless-wp-starter?

Thanks again

wickedst commented 5 years ago

After more research it seems docker is not supported in the latest version of Now https://spectrum.chat/zeit/general/sad-to-see-docker-not-supported-in-now-v2~d04c5b35-60b8-4f1c-b327-0a3f93999503

However someone might have a configuration for the front-end Next app?

dbvisel commented 5 years ago

I ran into this as well! It seems like the argument on the Now/Next Spectrum seemed to be that you shouldn't be using server.js with the new Now. I don't want to rework everything, so I'm staying with v1 despite the annoying warnings.

TechStacker commented 5 years ago

@dbvisel As far as I understand, the Now v1 service (with Docker support) will be shut down eventually. They’re moving completely away from it. Sure, at the moment 'legacy' sites with Docker can still be deployed with Now v1 — but nobody knows for how long

That kind of uncertainty makes me not want to use Zeit for my projects.

Unless I completely misunderstood Guillermo Rauch/Zeit’s recent statements (pretty sure I didn't).

Can anyone else chime in on this?

@wickedst next week I'm gonna try to deploy my backend on DigitalOcean and the frontend on Netlify — I'm not quite sure about how to go about it, but if I manage to do it I'll write a tutorial for it and link it here.

Please let me know if you discover something useful in the meantime =)

wickedst commented 5 years ago

I am going to go with a VPS (DigitalOcean) back end and for the front-end Next app I will use Now or the AWS PaaS option.

For the WordPress setup I wanted something preconfigured so I do not have to worry too much about security, caching or anything server related. I was considering the Roots suite but I saw DigitalOcean has a new OpenLiteSpeed WordPress one click install so I opted for that – it seems to have insanely good performance compared to a vanilla LAMP stack.

The final piece of the puzzle will be deployments and refactoring my repo, setting up local and production environment variables and so on. As far as WP I think I will set up automated deployments of the WordPress theme via Capistrano or something like that, and then manage the WordPress install manually for now.

On a side note – if any of the project authors are browsing here, is there any plans for a Slack or something similar where we could discuss topics like this?

wickedst commented 5 years ago

If anyone is curious the Now v2 deployment is pretty easy, I just followed the steps here: https://zeit.co/examples/nextjs-static/

dbvisel commented 5 years ago

If anyone is curious the Now v2 deployment is pretty easy, I just followed the steps here: https://zeit.co/examples/nextjs-static/

It seems like they've improved the documentation since they rolled out v2 – at first this didn't work at all.

But I already have an installation that's pretty dependent upon server.js for routing. I can't say that I'm excited about the prospect of reworking that entirely to make it work on a service that may change at any minute. I really don't want to go to AWS, but maybe that's where I'm headed.

wickedst commented 5 years ago

So I have an update on this – the now v2 deployment is not so easy as the serverless architecture means we can not / do not use the express server.js in production (we still need it for development purposes though).

Instead we add routes to the now.json file. I've put everything in a gist in case anyone who is interested in deploying this project to now finds this thread. It should be quite easy to see which lines you have to add / change in your project, and then simply do now in /frontend. Of course this is only for deployment of the frontend and not WP.

https://gist.github.com/wickedst/a65bf76c52e812539abc2ee7c16408aa

cordial commented 5 years ago

Have you actually managed to get this to work? I have copied your example but I am getting an issue that seems to be a conflict with wpapi and now v2. Which has been documented/discussed here -

https://spectrum.chat/zeit/now/trying-to-make-wordpress-work~c623bcf6-3853-4f79-a598-2b410501538b

did you not have this issue or perhaps did and got round it somehow?