Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUER UI for docker setup doesn't work. #520

Closed
skywormfol opened this issue Nov 8, 2023 · 46 comments
Closed

ISSUER UI for docker setup doesn't work. #520

skywormfol opened this issue Nov 8, 2023 · 46 comments
Labels

Comments

@skywormfol
Copy link

https://devs.polygonid.com/docs/issuer/setup-issuer-ui/#optional-using-the-ui

while setting up the ISSUER UI page according to above guidelines, an error is shown for "localhost:8088", any browser or "http://user-api:password-api@localhost:8088/." in NOTE doesn't solve it. What's the possible reason? Thanks.

"Something went wrong
An error occurred while reading the environment variables:
Invalid url at VITE_IPFS_GATEWAY_URL
Please provide valid environment variables."

image
@amonsosanz
Copy link
Contributor

Hi there! You're missing a value for the env var ISSUER_UI_IPFS_GATEWAY_URL in your .env-ui file. You can use https://ipfs.io or any other gateway.

This missing value has been already added in the develop branch as you can see here. It will be in main soon.

@skywormfol
Copy link
Author

Hi there! You're missing a value for the env var ISSUER_UI_IPFS_GATEWAY_URL in your .env-ui file. You can use https://ipfs.io or any other gateway.

This missing value has been already added in the develop branch as you can see here. It will be in main soon.

Thank you for your quick response, it solved my problem, but I got a new one when I launched the webpage, it shows as follows, do you know the possible reason? I cannot import schema as it reminds me "network error"...

image

Thanks a lot!

@amonsosanz
Copy link
Contributor

Can you please open the browser dev tools, go to Network, and show some details about the error on the request/response to the endpoint /schemas?

@Raj6939
Copy link

Raj6939 commented Nov 13, 2023

I am missing anything? this is the response in terminal when I run the command make run-ui.
Screenshot from 2023-11-13 18-51-48

@amonsosanz
Copy link
Contributor

This looks ok! Can you provide a video or screenshot of what you see in the Headers tab?

inspect-cors-error.mp4

@amonsosanz
Copy link
Contributor

Are you guys using ngrok by any chance?

@Raj6939
Copy link

Raj6939 commented Nov 13, 2023

@amonsosanz Yes I am using ngrok.

Screencast.from.13-11-23.07.15.13.PM.IST.webm

@amonsosanz
Copy link
Contributor

amonsosanz commented Nov 13, 2023

Can you please give LocalTunnel a try? We've had issues in the past with ngrok removing the header Access-Control-Allow-Origin, which produces this CORS issue.

EDIT:

Or open the port so the callback URL is publicly accessible.

@Raj6939
Copy link

Raj6939 commented Nov 13, 2023

Do I need to mention the url I got from localTunnel in env-api as ISSUER_API_UI_SERVER_URL= local tunnel url? or its value would be http://localhost:3002

@amonsosanz
Copy link
Contributor

Exactly, set up the public URL you get from LocalTunnel in ISSUER_API_UI_SERVER_URL (as I assume you were doing with the URL you got from ngrok) and restart the server.

@Raj6939
Copy link

Raj6939 commented Nov 13, 2023

I am getting the same error even after setting up a new LocalTunnel URL in env and restarting the server

@Raj6939
Copy link

Raj6939 commented Nov 13, 2023

How much images should run once we enter command as make up?
I hope my integration is right. correct me if i am doing wrong
image

@amonsosanz
Copy link
Contributor

Yep, this looks correct, but keep in mind that this command shows the containers that have been booted and some could go down later. To see what you currently have running use docker ps.

@Raj6939
Copy link

Raj6939 commented Nov 13, 2023

Yes I have tried ps command
is it correct or I am running less images than expected?
image

@Raj6939
Copy link

Raj6939 commented Nov 13, 2023

@amonsosanz I am trying to use Issuer-UI-API as mentioned in the documentation but not able to navigate to http://localhost:3002 as its not showing anything in a browser

@amonsosanz
Copy link
Contributor

amonsosanz commented Nov 13, 2023

its not showing anything in a browser

Yep, this is because your API service is down, along with redis. You should have these running:

$ docker ps 
CONTAINER ID   IMAGE                COMMAND                  CREATED          STATUS                    PORTS                    NAMES
755ce726cf0d   issuer-ui            "/bin/sh /app/script…"   34 minutes ago   Up 34 minutes             0.0.0.0:8088->80/tcp     issuer-ui-1
7db68e83a116   issuer-api           "sh -c 'sleep 4s && …"   52 minutes ago   Up 52 minutes             0.0.0.0:3001->3001/tcp   issuer-api-1
505a71889f5c   postgres:14-alpine   "docker-entrypoint.s…"   52 minutes ago   Up 52 minutes (healthy)   0.0.0.0:5432->5432/tcp   issuer-postgres-1
13f35a7df1b5   redis:6-alpine       "docker-entrypoint.s…"   52 minutes ago   Up 52 minutes (healthy)   0.0.0.0:6379->6379/tcp   issuer-redis-1
27a16c5e15ee   vault:1.13.2         "docker-entrypoint.s…"   52 minutes ago   Up 52 minutes             0.0.0.0:8200->8200/tcp   issuer-vault-1

EDIT: The above list is incomplete. Please check the complete list here.

I'd execute make down to stop everything.

Then make up should boot 3 containers.

$ make up
docker compose -p issuer -f /polygonid/issuer-node/infrastructure/local/docker-compose-infra.yml up -d redis postgres vault
[+] Building 0.0s (0/0)                                                                                                                                                                                                                            
[+] Running 4/4
 ✔ Network issuer-network       Created                                                                                                                                                                                                       0.0s 
 ✔ Container issuer-redis-1     Started                                                                                                                                                                                                       0.4s 
 ✔ Container issuer-vault-1     Started                                                                                                                                                                                                       0.4s 
 ✔ Container issuer-postgres-1  Started                        

And doing docker ps later should show them running.

$ docker ps
CONTAINER ID   IMAGE                COMMAND                  CREATED         STATUS                            PORTS                    NAMES
a1fa0725ef7a   postgres:14-alpine   "docker-entrypoint.s…"   5 seconds ago   Up 4 seconds (health: starting)   0.0.0.0:5432->5432/tcp   issuer-postgres-1
f01ea5f8991f   redis:6-alpine       "docker-entrypoint.s…"   5 seconds ago   Up 4 seconds (health: starting)   0.0.0.0:6379->6379/tcp   issuer-redis-1
d9566fb4dfcc   vault:1.13.2         "docker-entrypoint.s…"   5 seconds ago   Up 4 seconds                      0.0.0.0:8200->8200/tcp   issuer-vault-1

Then for Apple M1/M2 run make run-arm. Otherwise, run make run to start the issuer API.

Then if the API is booted (and does not die), you can optionally boot the UI with make run-ui-arm for Apple M1/M2 or make run-ui for other systems.

@Raj6939
Copy link

Raj6939 commented Nov 13, 2023

Thank you for the detail answer @amonsosanz . Sometimes redis goes down and sometimes API. I think waiting for some time after make down would be the solution

@Raj6939
Copy link

Raj6939 commented Nov 13, 2023

@amonsosanz When I run make run-ui the issuer-redis-1 comes as Created instead of Started.
can you tell Why its like that?

sudo make up
docker compose -p issuer -f /home/raj-patil/code/issuer-node/infrastructure/local/docker-compose-infra.yml up -d redis postgres vault
[+] Running 4/4
 ✔ Network issuer-network       Created                                                                                                         0.1s 
 ✔ Container issuer-redis-1     Created                                                                                                         0.2s 
 ✔ Container issuer-postgres-1  Started                                                                                                         0.2s 
 ✔ Container issuer-vault-1     Started                                                                                                         0.2s 

@amonsosanz
Copy link
Contributor

Nope. Is it running later when you run a docker ps?

By the way, I've just realized that you (and me 😅) are missing another service: issuer-api-ui-1.

This is the actual API used by the UI. It's been a while since I ran this project locally, let me investigate this and come back to you ASAP.

@Raj6939
Copy link

Raj6939 commented Nov 13, 2023

No After run docker psthese are the running images I get.

image

@amonsosanz
Copy link
Contributor

Can paste the output of docker start issuer-redis-1 && docker logs issuer-redis-1?

@Raj6939
Copy link

Raj6939 commented Nov 14, 2023

@amonsosanz Sure, I am getting this error after running above command


sudo docker start issuer-redis-1 && docker logs issuer-redis-1
Error response from daemon: driver failed programming external connectivity on endpoint issuer-redis-    (b78bcc1a7376f38867160be9086160f639d56b55b178a9ed320c88861825974a): Error starting userland proxy: listen tcp4 0.0.0.0:6379: bind: address already in use
Error: failed to start containers: issuer-redis-1

@amonsosanz
Copy link
Contributor

mmm... apparently the port is in use. Do you have any other service on this port? Without this port redis can't start.

I'd stop all the containers docker stop $(docker ps -a -q) and try to guess who's using the port lsof -i -P -n | grep 6379.

Being on Windows, I'd also advise restarting, just in case.

@amonsosanz
Copy link
Contributor

I fixed a problem I had in my local environment and now I have all the containers running. Sorry about my imprecise comment yesterday. I've not worked on this project lately. This is the complete list of containers you should have running:

$ docker ps
CONTAINER ID   IMAGE                      COMMAND                  CREATED         STATUS                  PORTS                    NAMES
8fcb6b0c93ee   issuer-api-ui              "sh -c 'sleep 4s && …"   9 minutes ago   Up 9 minutes            0.0.0.0:3002->3002/tcp   issuer-api-ui-1
29931c841d67   issuer-ui                  "/bin/sh /app/script…"   9 minutes ago   Up 9 minutes            0.0.0.0:8088->80/tcp     issuer-ui-1
e6b0094a8985   issuer-pending_publisher   "sh -c 'sleep 4s && …"   9 minutes ago   Up 9 minutes                                     issuer-pending_publisher-1
2f16c5411050   issuer-notifications       "sh -c 'sleep 4s && …"   9 minutes ago   Up 9 minutes                                     issuer-notifications-1
9918e0538d6f   issuer-api                 "sh -c 'sleep 4s && …"   17 hours ago    Up 17 hours             0.0.0.0:3001->3001/tcp   issuer-api-1
a1fa0725ef7a   postgres:14-alpine         "docker-entrypoint.s…"   18 hours ago    Up 17 hours (healthy)   0.0.0.0:5432->5432/tcp   issuer-postgres-1
f01ea5f8991f   redis:6-alpine             "docker-entrypoint.s…"   18 hours ago    Up 15 hours (healthy)   0.0.0.0:6379->6379/tcp   issuer-redis-1
d9566fb4dfcc   vault:1.13.2               "docker-entrypoint.s…"   18 hours ago    Up 17 hours             0.0.0.0:8200->8200/tcp   issuer-vault-1

Now that we know that this project has 8 services, let's see what's wrong on your end. First, though, you should be able to make Redis run. Let's first focus on this and later we will make the rest work.

I hope all this is somehow helpful for you too @skywormfol. We hijacked your threat...

@Xiaod0ng
Copy link

Hi team, a similar problem here. I was able to start the docker service for the first time, the UI page can be opened without problem. However, if the docker service is stopped, what's the proper way to resume the services? If I start the docker service in docker directly, or use make run, make run-ui to start the service, issuer-ui image is always not started.
image
Inside the docker image, it has log: /bin/sh: can't open '/app/scripts/deploy.sh': No such file or directory

@amonsosanz
Copy link
Contributor

Hi @Xiaod0ng. Thx for reporting this issue. I'm able to reproduce it.

Apparently, the entry point of the docker image, the deploy script, gets removed by the script itself, making the UI run only the first time.

While we investigate the issue, you can re-run the UI service after it has been stopped by removing the image. This should not imply a rebuild of the complete image thanks to docker layering:

docker rm issuer-ui-1 && make restart-ui

or for Mac

docker rm issuer-ui-1 && make restart-ui-arm

@Xiaod0ng
Copy link

@amonsosanz Thank you for your prompt reply! The command can resolve the issue but it does rebuild the ui. I will test more to see if it really works. Will keep you updated.
image
BTW, for the network issue mentioned in above thread, if I run make run, then make run-ui, it won't have the error. If I run make run-ui only, it will show the error. Didn't try many times, do don't guarantee it can be reproduced stablely.

@amonsosanz
Copy link
Contributor

I believe it's normal that the UI image is not rebuilt unless there are other changes.

I've opened a PR fixing the issue you reported here.

BTW, for the network issue mentioned in above thread, if I run make run, then make run-ui, it won't have the error. If I run make run-ui only, it will show the error. Didn't try many times, do don't guarantee it can be reproduced stablely.

The "Network error" happens when for some reason the service running the API consumed by the UI (issuer-api-ui) fails to boot. This can happen for several reasons.

In the case of @Raj6939, apparently, he has an issue booting the Redis cache and therefore several containers fail booting.
In the case of @skywormfol, we don't know yet the source of the issue. It might be related to the vault, the generation of the DID, or anything else.

@Xiaod0ng
Copy link

Hi @amonsosanz , to add something to this issue, all my images are running (8 in total) and it's normal when openning from my laptop where hosting Docker. But when openning with my mobile phone, it's showing network error. I also tried with localtunnel to setup the public URL, but same behavior
new ducument

@amonsosanz
Copy link
Contributor

Can you please show here the settings/commands you use to run both ngrok and localtunnel?

@Xiaod0ng
Copy link

@amonsosanz Here you go:

ngrok: ngrok http --domain usefully-blessed-sunbird.ngrok-free.app 8088, usefully-blessed-sunbird.ngrok-free.app is the customized domain ngrok assigned to me.

localtunnel: lt --port 8088

@amonsosanz
Copy link
Contributor

amonsosanz commented Nov 22, 2023

Ok, there it's the issue, you need to make publicly accessible the API (port 3002) and optionally the UI, as you already do.

You can keep using ngrok for the UI (port 8088) and then use local tunnel for the API with lt --port 3002. Then you need to set the publicly accessible URL of the API in the ISSUER_API_UI_SERVER_URL of the file .env-api and restart the api-ui container.

If you wonder, the reason to use local tunnel and not ngrok for the API is that some users have experienced CORS issues with ngrok removing the header Access-Control-Allow-Origin.

@Xiaod0ng
Copy link

@amonsosanz Hi, it still has the same error when openning with mobile browser. I have followed your instructions, settings are as following.
In .env-api:
ISSUER_API_UI_SERVER_URL=https://tame-items-lay.loca.lt while the value is what localtunnel returned.
In .env-issuer:
ISSUER_SERVER_URL=https://usefully-blessed-sunbird.ngrok-free.app/ while the value is customized ngrok domain.
api-ui-1 container is restarted after setting the values.

@amonsosanz
Copy link
Contributor

Have you restarted the API container?

docker restart issuer-api-ui-1

@Xiaod0ng
Copy link

@amonsosanz Yes, the container was restarted after setting the variables.

@amonsosanz
Copy link
Contributor

Sorry, you're right, the UI env vars are calculated in the image. You need to run:

make restart-ui

@Xiaod0ng
Copy link

@amonsosanz Hi, I don't think it's right. I got network error even on my local computer. The error message in console is: Failed to load resource: the server responded with a full-mirrors-crash.loca.lt/v1/schemas:1 status of 511. full-mirrors-crash.loca.lt is localtunnel public URL.
image
I'm not sure whether it's related to this error from localtunnel.
image

Could you please let me know whether the following is correct? I will try to host the sites in Azure instead of ngrok or localtunnel.
ISSUER_API_UI_SERVER_URL with port 3002 should be public;
ISSUER_SERVER_URL with port 3001 should be public.
Anything missing?

@amonsosanz
Copy link
Contributor

The setup you were attempting is pretty common for testing. Let's give it one more try before Azure.

You only need to open in the browser the URL that localtunnel gives you. An input text should appear to enter your IP
so it can be whitelisted. After doing so, it should work.

@Xiaod0ng
Copy link

@amonsosanz Hi, If I open the URL from localtunnel, it's API UI, not the UI. If I open ngrok URL, it's using previous localtunnel URL instead of the new output from localtunnel command. The env file is updated to latest URL and UI restarted with make restart-ui. It seems so confusing to me.
image

I appreciate if we can have a remote session or use other method to troubleshoot this issue.

@amonsosanz
Copy link
Contributor

amonsosanz commented Nov 25, 2023

I've recorded a quick video showing you how I set up this in my local environment.

https://drive.google.com/file/d/1oA5qtoQhREGaSHO3P_YOpj7PY-I7Bfac/view

The video is public, but I think you have to be logged in on a Google account to access it.

@Xiaod0ng
Copy link

Xiaod0ng commented Nov 25, 2023

@amonsosanz Thank you for your time! I finally got what you mean. But I'm having another issue right now, I will give it a try after fixing that one. Thanks again! BTW, are you able to use your mobile/tablet/other computer to open the UI URL?

@amonsosanz
Copy link
Contributor

I did not test it but yep it should work the same. The issue you had initially is that the UI was pointing to localhost, which is only available in the computer. Now that the change has been applied and you're using local tunnel, after white-listing your IP, you should be able to use the UI from other devices.

Take into account though that our UIs are not yet very mobile friendly, we will be improving this with the time.

@Xiaod0ng
Copy link

@amonsosanz Hi, I'm able to get it work now. The trick is about whitelist my IP in localtunnel. Thank you!

@amonsosanz
Copy link
Contributor

Awesome! Thank you for your patience!

Copy link

This issue is stale because it has been open 20 days with no activity. Remove stale label, add the enhancement label or comment to avoid closing it in 10 days.

@github-actions github-actions bot added the Stale label Dec 20, 2023
Copy link

This issue was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants