go-skynet/LocalAI-frontend

Issues running in docker

Closed this issue · 12 comments

Joly0 commented

I am trying to set this up in docker according to this documentation https://github.com/go-skynet/LocalAI/tree/master/examples/localai-webui
Unfortunately the api address for the webui cannot be set. If i change the "ADDRESS" value in the env file, the api container doesnt start up due to an error. But i can change the "ChatGptInterface.js" file in the webui container and adjust the address there and that seems to be working (looking at the developer tools in firefox), but i get alot of CORS errors and i cant select any models in the webui.

Is this a bug or did i setup something wrong?

I am trying to set this up in docker according to this documentation https://github.com/go-skynet/LocalAI/tree/master/examples/localai-webui Unfortunately the api address for the webui cannot be set. If i change the "ADDRESS" value in the env file, the api container doesnt start up due to an error. But i can change the "ChatGptInterface.js" file in the webui container and adjust the address there and that seems to be working (looking at the developer tools in firefox), but i get alot of CORS errors and i cant select any models in the webui.

Is this a bug or did i setup something wrong?

That was how it was working, now you can set the URL from the config file!

Joly0 commented

Sry, but this is still an issue. First, there is no documentation on how to use the new variable. I have more or less figured it out by myself and added "REACT_APP_API_HOST=API_IP:API_PORT" to the env file and added that to my compose file in the section for the frontend, but this isnt anywhere in the documentation or the default compose file.

But even then, no models are found and i get these errors
image
image

Joly0 commented

I tried to request the exact endpoint using postman and get this result
image

Sry, but this is still an issue. First, there is no documentation on how to use the new variable. I have more or less figured it out by myself and added "REACT_APP_API_HOST=API_IP:API_PORT" to the env file and added that to my compose file in the section for the frontend, but this isnt anywhere in the documentation or the default compose file.

But even then, no models are found and i get these errors image image

That's not how it's supposed to be done, either you can export the API_HOST variable in your environment, or you can edit the entrypoint.sh API_HOST variable, the way you set it, entrypoint must have overwritten it to localhost instead

Joly0 commented

Ok, so adding "API_HOST=http://API_IP:API_PORT" should work then, right? Atleast it looks like its more or less working now, but i keep getting cors errors like before

Joly0 commented

image

Joly0 commented

I am using the host ip adress for the container, as the internal ip could change more frequently instead of the external one. Unfortunately i cant use the hostname of the container. If i try that, i get this error: "ChatGptInterface.js:115 GET http://local_ai_webui-api:8080/v1/models net::ERR_NAME_NOT_RESOLVED"

Ok, so adding "API_HOST=http://API_IP:API_PORT" should work then, right? Atleast it looks like its more or less working now, but i keep getting cors errors like before

Yes, make sure to use the public IP, or reverse proxy the public IP with Apache, I have tested with reverse proxy as well as public IP and both work. Make sure to use https if setup and port redirection with Apache if you use that

Joly0 commented

Ok, let me get this correct. I have a server with ip 10.10.1.20 in my local network and when i use docker compose it creates a docker network using 172.xx.0.yy.
I cant use the hostname of the container, which would be "local_ai_webui-api" for the api and "local_ai_webui-frontend" for the frontend. That results in a "net::ERR_NAME_NOT_RESOLVED" error.
I cant use the 172.xx.0.yy ip, so the internal docker ip of the containers to comunicate with each other, because that is changing basically everytime i startup the compose stack, i could set this fixed, but that would result in other errors.
I cant use the 10.10.1.20 ip of my server with the appropriate port that i have specified for the container (8080:8083), because that results in a CORS error
And i am not willing to setup any kind of reverse proxy for a service that i only want to use in my local network for testing atm.
So how am i going to connect these two together now, so the frontend can access the api correctly?

Ok, let me get this correct. I have a server with ip 10.10.1.20 in my local network and when i use docker compose it creates a docker network using 172.xx.0.yy. I cant use the hostname of the container, which would be "local_ai_webui-api" for the api and "local_ai_webui-frontend" for the frontend. That results in a "net::ERR_NAME_NOT_RESOLVED" error. I cant use the 172.xx.0.yy ip, so the internal docker ip of the containers to comunicate with each other, because that is changing basically everytime i startup the compose stack, i could set this fixed, but that would result in other errors. I cant use the 10.10.1.20 ip of my server with the appropriate port that i have specified for the container (8080:8083), because that results in a CORS error And i am not willing to setup any kind of reverse proxy for a service that i only want to use in my local network for testing atm. So how am i going to connect these two together now, so the frontend can access the api correctly?

Check the documentation for creating a docker network and accessing the api from the container under that, it should resolve all these issues

Joly0 commented

I know how to do this and i do know, that this would fix the issue, but as i said, i dont want to setup a separate docker network for testing a compose stack. Docker compose is there to eliminate such things as manual setup of certain things (a custom network in this case). So imho this should work without forcing the user to setup a docker network first. This isnt very intuitive like this.
I could define a docker network with an ip in the compose file, but that way if another service is by chance (and that chance isnt small) using the same ip range, then theis method wont work again and we are back at root one.

So the only solutions would be to allow using the hostname of the api container, as thats quite simple to setup in the compose file (this would need some addition on your provided compose file and some documenation of the environment variable) or/and fixing that CORS error.