I'm wondering why the docker image is 3.7 GB

I managed to get a test instance up and running locally on my NAS with a very simple docker-compose.yml using libretranslate/libretranslate:latest to avoid building my own image.

Here it is:

version: "2.4"                                                                                                                                                                                                                                                                                                       
    image: libretranslate/libretranslate:latest                                                                                                                                                                                                                                                                      
    container_name: libretranslate                                                                                                                                                                                                                                                                                   
    hostname: libretranslate                                                                                                                                                                                                                                                                                         
    restart: "no"                                                                                                                                                                                                                                                                                                    
      - 7500:5000                                                                                                                                                                                                                                                                                                    
      LT_DEBUG: true                                                                                                                                                                                                                                                                                                 
      LT_FRONTEND_LANGUAGE_SOURCE: de                                                                                                                                                                                                                                                                                
      LT_FRONTEND_LANGUAGE_TARGET: en                                                                                                                                                                                                                                                                                
      LT_LOAD_ONLY: 'de,en'                                                                                                                                                                                                                                                                                          
      LT_THREADS: 4                                                                                                                                                                                                                                                                                                  
      LT_SUGGESTIONS: true                                                                                                                                                                                                                                                                                           
        - libretranslate                                                                                                                                                                                                                                                                                             
    cpus: 2                                                                                                                                                                                                                                                                                                          
    mem_limit: 4G                                                                                                                                                                                                                                                                                                    
    external: true                                                                                                                                                                                                                                                                                                   
    name: libretranslate

here are a few questions related to this:

  • can I map a volume to a certain path to avoid downloading language files with every restart?
  • why ist the image at around 3.7 GB, this seems highly unusual and at a first glance with:
docker exec -ti libretranslate bash
[email protected]:/app$ ls -al

I am wondering whether all of that is really necessary as it looks like the complete git repo is inside there (only at a glance of course).

docker exec -ti libretranslate bash
du -cksh /app/venv/lib/*

reveals that /app/venv/lib/python3.8/ is 2.5 GB

It might be possible to optimize the image size, I don’t think a whole lot of work has gone into it. That said, most of the size will be from the language models and the pip dependencies.

You should be able to map $HOME/.local/share/argos-translate to a local folder for the models.