Closed dwehrmann closed 5 years ago
You shouldn't use gatsby serve
in production, it's only for testing purposes. Please use a webserver like nginx
! Most people (also Netlify does that afaik) build their site in another directory and then copy over the files to the www
of the webserver.
Please let us know if you need further help with that, thanks!
@LekoArts Hmm okay thanks, I understand. Nginx only serves me a list of all the files in the public directory, not the actual website – but I recognize that would be a nginx config issue on my side. Just out of curiosity, where are the downsides with gatsby serve
? I am running it with pm2 and it works pretty well so far, nginx currently does the reverse proxy.
Yes, I have gone exactly the path you described, building in one gatsby directory and then rsync
ing the files over into the other gatsby/public directory that is served by gatsby serve
. Swapping gatsby serve
for Nginx would of course allow me to trash the second gatsby installation which makes sense. I will have to look into the nginx config issue then. Thank you!
I was wondering whether it is possible to have a custom output folder for
gatsby build
andgatsby serve
.Here's my use case: We have a gatsby site deployed on a root server (netlify can not be used for our project) via
gatsby serve
. We have decided against webhooks, instead the site is re-built every hour via cronjob. Whenever the new build process starts, gatsby wipes its public folder, thus leaving the site non-accessible for visitors. It takes roughly 12 minutes for the build process to finish during which the sites appears "offline" for visitors. Makes roughly 2,5 hrs. downtime a day which is not acceptable of course.I was looking for a way to have a different
build
output folder and anotherserve
folder so that I can have the site built and after a successful build copy over the new contents into the served folder but that currently seems not possible with gatsby – am I correct?I'd be happy to hear what the best approach would be.