在Docker容器中向Reportlab添加字体

问题描述

我有一个在3个单独的容器中运行的应用程序。一种用于django应用程序,一种用于Postgresql,第三种用于Nginx。在我的docker-compose文件中,我有放上font.ttf文件静态文件卷。我检查了容器,并且文件在那里,但是没有被加载。这是Web容器的设置:

web:
    image: ashowlsky/foodgram:latest
    restart: always
    command: gunicorn foodgram.wsgi:application --bind 0.0.0.0:8000
    volumes:
      - ./static:/code/static/
      - ./media:/code/media/
    ports:
      - "8000:8000"
    depends_on:
      - db
    env_file:
      - ./.env

这是视图的一部分:

pdfmetrics.registerFont(TTFont('OS','/code/static/OpenSans-Regular.ttf'))

Nginx.conf文件的一部分,用于静态文件

location /static/ {
            include /etc/Nginx/mime.types;
            autoindex on;
            alias /code/static/;
        }

我该怎么办?

解决方法

检查了一段时间的容器后,我了解到docker只是在使用映像的过时版本。就我而言,解决方案是docker-compose pull ...