INSPIRE-MIF / helpdesk-validator

Community discussion forum for INSPIRE validation issues
41 stars 22 forks source link

Frontend config.js inside the container #1051

Open ZakarFin opened 3 months ago

ZakarFin commented 3 months ago

I'm trying to setup the docker container that has been uploaded to GitHub packages as is, but it seems only works if run on localhost. The ui.zip in both 2024.0.0 and 2024.0.1 has this config.js file included validator\js\config.js that points to http://localhost:8090. I can't find any configuration option to override this and it basically means that when the user clicks the "Start test" button on Test selection page OR accesses the Test reports page the browser tries to call the localhost instead of the service that the page is shown from. Also I can't find the repository that hosts this ui.zip (it's only included in the release version package as binary zip-file?)

validator/js/config.js has this:

var serverURL = "http://localhost:8090/validator/v2/";
var serverRealURL = "http://localhost:8090/validator/v2/";
var serverDirectURL = "http://localhost:8090/validator/v2/";
var serverCaptchaURL = "http://localhost:8090/validator/captcha/verify";
var swaggerURL = "http://localhost:8090/validator/swagger-ui.html"

A simple solution would be to only include the path, not the server/domain part so the frontend would call the service that it's hosted on:

var serverURL = "/validator/v2/";
var serverRealURL = "/validator/v2/";
var serverDirectURL = "/validator/v2/";
var serverCaptchaURL = "/validator/captcha/verify";
var swaggerURL = "/validator/swagger-ui.html"

What is your take on the container that is hosted on https://github.com/INSPIRE-MIF/helpdesk-validator/pkgs/container/helpdesk-validator%2Finspire-validator? Should it not be used as is, but users should create their own dockerfile/with their own UI.zip instead? Or am I missing something that would let me specify the domain the service is running in?

image

ZakarFin commented 2 months ago

Any updates for this one? If this won't be changed we will have to build our own version of the container.

lindsejs commented 2 months ago

yes, this is frustrating, I am building my own image with dockerfile:

FROM ghcr.io/inspire-mif/helpdesk-validator/inspire-validator:2024.0.1

# change /docker-entrypoint.sh file:
# add line to update UI JS config from env variable

RUN sed -i "s|# Download Webapp|sed -i 's}http://localhost:8090}'\"\$HOSTNAME_IN_JS_CONFIG\"'}g' /etf/validator/js/config.js \n\n # Download Webapp|g" /docker-entrypoint.sh

And passing env variable in docker-compose:

validator:
    build:
      context: ./
      dockerfile: ./docker/validator.dockerfile
    environment:
      - HOSTNAME_IN_JS_CONFIG=http://localhost:8070
    ports:
      - "8070:8090"
DanielMartinPerezdeLeon commented 2 months ago

Dear @ZakarFin,

Apologies for the delay in getting back to you. In order to host the validator in a non-local environment, it's essential to include the complete endpoint of the validator in the config.js file. For instance, in the production environment, we utilize https://inspire.ec.europa.eu/validator/v2/.

Regarding the URL of the UI repository, you can find it here: https://github.com/inspire-eu-validation/INSPIRE-Validator-UI.

If you have any further questions or encounter any issues, please don't hesitate to reach out.

Best regards,

ZakarFin commented 2 months ago

Hi @DanielMartinPerezdeLeon,

Thanks for the answer. So this basically means that the image cannot be used as is even with configuration and making your own version is always required. Any chance on making this configurable?

Can you point to something specific that breaks if I use config.js without the domain part? It seems to work just fine on my instance without the domain part, but I might be missing something. What should I expect to not work if the domain is not included?

Thanks!

jenriquesoriano commented 2 months ago

Dear @ZakarFin ,

in case you are configuring a specific deployment, you can do it following the instructions provided in the release notes.

The Docker image is set up to run at localhost to be deployed on any machine. However, users may need to access their validator on a dedicated host, usually with a domain name. For proper functioning of the validator, the UI and correct rendering of Test Reports, the validator needs to be configured to run on a domain.

If you want to run the webapp in another host, you can change the configuration file, inside the .war file inside the inspire-validator zip file accompanying this release, at WEB-INF/classes/etf-config.properties, and modify the etf.webapp.base.url property. It is also necessary to configure the Validator UI properties in order to properly point to the ETF. Thus, it is necessary to modify the configuration values in the /validator/js/config.js file inside the ui.zip (to point to the corresponding host domain). Then you can proceed to the build process described in the previous point.

Please note this involves not only the UI configuration but also the validation endpoint to be requested from the UI.

Best regards,