I am currently using this Dockerfile to build my backend service:
FROM python:3.9-busterENV PYTHONUNBUFFERED 1WORKDIR /appCOPY requirements.txt /app/requirements.txtRUN pip install -r requirements.txtCOPY . /appCMD python manage.py runserver 0.0.0.0:8002
I also have a mysql database the Docker-compose file is:
version: '3.8'services: dj: build: context: . dockerfile: Dockerfile ports: - 8000:8002 volumes: - .:/app depends_on: - db db: image: mysql:5.7.22 restart: always environment: MYSQL_DATABASE: ... MYSQL_USER: ... MYSQL_PASSWORD: ... MYSQL_ROOT_PASSWORD: ... volumes: - .dbdata:/var/lib/mysql ports: - 33068:3306
I want to reduce the size of my container which is currently 1.2G any detailed explanation on how to do that would be helpful, precisely I want to know how to do a multisatge build or use a lighter base image properly because I looked at some blogs that use the alpine as their base image but that doesn't work for me probably because my requirement.txt:
Django==3.1.3djangorestframework==3.12.2django-cors-headers==3.5.0djangorestframework-simplejwt==4.7.1pyjwt==2.1.0mysqlclient==2.0.1django-mysql==3.9
doesn't include everything needed.I am not sure if this is the right place to ask the question I already posted it on SO hours ago but got no answer.