Our website was functioning normally for a time as we tried to deploy a Flask Docker container to AWS Elastic Beanstalk. Because we began our Docker container with pip freeze in a non-virtual environment, we had more dependencies listed in requirements.txt than we were really using, resulting in a huge (5GB) container.
We attempted adding Java installation to our Dockerfile after running into a difficulty with a library (Apache Tika was working normally locally, but we were getting an error on the deployment hinting that we needed to instal Java).Since we've attempted this, nothing—not even our old repository—can be deployed on AWS. When we use "docker build," the old pip dependencies are STILL being installed and the Docker container is BIGGER, not smaller, even though I've tried deleting the Java installation and all extraneous pip dependencies from requirements.txt.
Our Dockerfile looks like:
# Set the working directory and install the requirements
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
# Expose port 5000 and copy the source code
COPY . .
# Run the application using gunicorn
CMD ["gunicorn", "wsgi:app", "-w 2", "-b 0.0.0.0:5000", "-t 30"]
What we have tried:
What could be causing the massive size of the Docker container? How can we resolve this issue and successfully deploy the Docker container to AWS Elastic Beanstalk?