INL / corpus-frontend

BlackLab Frontend, a feature-rich corpus search interface for BlackLab.
16 stars 7 forks source link

Where to modfiy the Blacklab server URL when deploy this repo in a decoupled way? #472

Closed fishfree closed 5 months ago

fishfree commented 5 months ago

I'd like to deploy this great repo the decoupled way: this Vuejs frontend app in server A, and the Java Blacklab backend server in server B.

Is it possible? If so, where to modfiy the Blacklab server URL? I searched nowhere to configure in the Vuejs codes: https://github.com/search?q=repo%3AINL%2Fcorpus-frontend%20localhost&type=code

KCMertens commented 5 months ago

Heya! The url comes from a setting in the corpus-frontend.properties config file. The server exports it as BLS_URLon the html pages. Here's how to change it:

fishfree commented 5 months ago

@KCMertens Thank you! The corpus-frontend.properties config file is used by docker-deployment way. But I doubt if the ***.properties file will be ignored by pure frontend package command npm install && npm run build?

KCMertens commented 5 months ago

Oh, I think I misunderstood your question. You can't deploy the frontend and backend separately at the moment. The java backend creates the initial html page, and it's responsible in a large part for rendering documents. It also serves the .js/.css files, etc.

Quite a bit of work would be needed to completely split the frontend and backend, and I don't think it's worth it at the moment. Main sticking points are that search.xml would need to become a json file the frontend uses, and xslt transformations would need to be ported from saxon-java to saxon-js in the browser.

jan-niestadt commented 5 months ago

Just to add to this: if you're using the Dockerfile supplied with this repo: that's derived from the BlackLab image, so it combines everything together: the BlackLab webservice and the frontend (which itself contains a Java backend and a Vue-based frontend, but these are combined into a single .war file).

I think this makes sense because webservice and frontend are both just Tomcat .war applications. Another advantage is that, once you've built this image (or use a publicly available one), you can't accidentally use incompatible versions of the webservice and frontend.

Of course, nothing is stopping you from writing your own Dockerfile for the frontend. You'd run the BlackLab webservice in its own image and the frontend in the image built from your Dockerfile (based on the Tomcat base image, not the BlackLab image like now). That way you're free to deploy the webservice and frontend to different servers if you want to. If you do this, you'll need @KCMertens's original advice about configuring the blsUrl in corpus-frontend.properties.

fishfree commented 5 months ago

Thank you both! @jan-niestadt If I try to deploy tge decoupled way, where to modify the BLS_URL variable value even hard-coded way in the Vuejs app?

KCMertens commented 5 months ago

You can't. The page is not static html, so you can't decouple it from the java code easily.

jan-niestadt commented 5 months ago

I'm not sure exactly what you mean when you say "deploy the decoupled way".

The frontend is a combination of Vue.js and Java which are not easily separated like @KCMertens says. If I understand correctly, if you configure blsUrl in corpus-frontend.properties, BLS_URL will be set correctly in the page as well.

The frontend and BlackLab can be decoupled, that is, deployed separately, as I described above.

fishfree commented 5 months ago

@jan-niestadt I mean how to inject the BLS_URL environment variable into the Vue.js frontend app? It was injected by the Tomcat or other Web server. Now If I deploy it the decoupled way, how to inject BLS_URL?

jan-niestadt commented 5 months ago

BLS_URL is automatically set to the same value as blsUrl in corpus-frontend.properties. Did you try that?