Building python wheel via docker-compose on AWS EC2 gets stuck

Viewed 448

I have a docker container that builds fine on my laptop (iOS) and my PC (Ubuntu 20.4). I am trying to build it on AWS EC2 instance(Ubuntu 18.04) but it gets stuck at the following line while installing requirements.txt for python:

Building wheel for lxml (setup.py): started

It does not show an error just gets stuck. On my laptop/PC this bit takes about 2 minutes (which is longer than others that take much less). I've now been waiting for over 2 hours for this to finish, which kind of rules out performance issues (surely it can't be THAT slow?).

Docker-compose and docker versions are the same (latest) on all machines.

Any ideas what might be causing this, and how long it is reasonable to wait for? I thought docker should be independent of host, providing docker versions were the same.

1 Answers

From the discussion in the comment, the instance is small enough which hit 99% CPU usage and 60-70% Memory usage so instance becomes unresponsive.

So possible two option that you can try

  • Move all build task to docker image and build the image locally and push the image to ECR and just run the docker image over Ec2 instead of building docker image or wheel on Ec2 machine.

By doing this you will be able to run your application with t2.micro by taking advantage from free tier.

Or

  • Upgrade instance some higher specs, which have more VCPU, if t2.micro does not work, then possibly t2.small instance will work.
Related