Need desperate help deploying a streamlit app using ECR + ECS on AWS. Unsure if networking issue or something else

252 views Asked by At

I have to deploy a streamlit app on AWS so I am using ECR + ECS. I have tested the docker image locally and it works perfectly fine, but once I upload the image to ECR and try to deploy it on AWS ECS shit starts breaking down and I am finding it very difficult to pinpoint exactly where the problem may be.

I have got a streamlit app, I dockerize it and deploy it locally to test and it works perfectly fine. The dockerfile is as such: DOCKERFILE https://imgur.com/Zp71oGN - dockerfile

I made my cluster on ECS on a brand new VPC that I made with two PUBLIC available subnets, which both go through a route table and have internet gateway access.

For the ECS task definition, these are my settings:

https://imgur.com/xH05CoG - initial settings for ECS task def. https://imgur.com/bMzt8kH - more settings for ECS task def. Here are some of the port mappings

After making the task definition and running it on my cluster, I can look at the logs and I see this: https://imgur.com/PXXRYP2 - This shows that it is indeed running on 0:0:0:0:PORT

It provisions properly and is running smoothly, and here are my inbound outbound rule settings from the EC2: https://imgur.com/FEY3shK - inbound outbound rules from EC2


I seriously don't understand what the issue may be, I even nuked the entire VPC and made a brand new fresh VPC with two publicly available subnets with internet access and hosted my ECS cluster on that which deploys the instance on it. I edited my dockerfile to ensure that I expose the port and open it up, I made sure I have the correct port mappings in the task definition, I have also opened up like every single inbound rule at this point I don't even know what the issue may be, have you encountered anything like this? This is the error I get from chrome when I try to connect, https://imgur.com/QBBWovy when I change the port to something random (like one that I DID NOT expose) it takes a LONGGG time to load, the loading icon just keeps spinning, but if I use the correct port, I instantly get the previous error in the imgur. Lastly, yes, I tried switching the port too, I initially tried 8501, the default streamlit port and then I am now trying 8000 and still no luck.

1

There are 1 answers

0
Andrey Mazur On

I had the same issue. Please use this tutorial https://www.youtube.com/watch?v=o7s-eigrMAI&t=1169s Following steps should be done:

  • replace the flask app with your streamlit app
  • replace port 8080 to 8501 everywhere