I've got a JSS application created using Next.js Getting Started template. During development, when I have local Sitecore instance runnung, I can build the app using jss build
command. On the CI server the app is being built when the rendering
container starts which seems too late. If there are build errors, the container will never start. See the Docker file fragment:
EXPOSE 3000
ENTRYPOINT "npm run start:connected"
To prevent that, I'd like to build next.js app in advance. Ideally, on a pull request validation. But, if executed without Sitecore instance running, the jss build
fails with connection error:
info - Creating an optimized production build
info - Compiled successfully
> Build error occurred
FetchError: request to https://cm.localhost/sitecore/api/graph/edge failed, reason: connect ECONNREFUSED 127.0.0.1:443
It even does what I need - compiles the frontend app. It just needs to be stopoed before sending the request to Sitecore. How to do that?