Всем привет, у меня сайт на docker, NGINX + DJANGO + POSTGRESQL + CELERY. Я в базе храню текстовые файлы, они у меня находятся на nginx контейнере, и я не могу получить их, когда пытаюсь открыть файл:
def read_members(group):
group = get_object_or_404(UserGroup, id=group)
print(group.members.path)
with open(group.members.path, mode='r', encoding='UTF-8', errors='strict', buffering=1) as file:
members = file.readlines()
Получаю ошибку:
FileNotFoundError: [Errno 2] No such file or directory: '/var/www/site/media/activities/user_group/users.txt'
docker-compose
version: '3'
services:
backend:
build: ./
container_name: site_container
restart: always
command: ./commands/start_server_${MODE}.sh
ports:
- "${PORT}:${WSGI_PORT}"
volumes:
- .\src:/srv/project/src
- .\commands:/srv/project/commands
- .\src\media:/srv/project/media
- static_content:/var/www/site
env_file:
- .env
environment:
- DJANGO_SETTINGS_MODULE=app.settings.${MODE}
depends_on:
- postgres
postgres:
image: postgres:12
# environment:
# - POSTGRES_PASSWORD=mysecretpassword
volumes:
- pg_data:/var/lib/postgresql/data
ports:
- "5432:5432"
env_file:
- .env
nginx:
image: nginx:1.19
volumes:
- .\nginx:/etc/nginx/conf.d
- static_content:/var/www/site
ports:
- 80:80
- 443:443
env_file:
- .env
depends_on:
- backend
rabbitmq:
image: rabbitmq:3.8-management-alpine
# ports:
# - 8181:15672
env_file: .env
restart: always
redis:
image: redis
env_file: .env
restart: always
redis-commander:
container_name: redis-commander
hostname: redis-commander
image: rediscommander/redis-commander:latest
restart: always
environment:
- REDIS_HOSTS=redis
ports:
- "8081:8081"
celery:
env_file: .env
build: .
command: ./commands/start_celery.sh
restart: always
depends_on:
- redis
- rabbitmq
environment:
- DJANGO_SETTINGS_MODULE=app.settings.${MODE}
volumes:
- ./src:/srv/project/src
- ./commands:/srv/project/commands
celerybeat:
env_file: .env
build: .
container_name: celerybeat
command: ./commands/start_celerybeat.sh
restart: always
depends_on:
- redis
- celery
- rabbitmq
environment:
- DJANGO_SETTINGS_MODULE=app.settings.${MODE}
volumes:
- ./src:/srv/project/src
- ./commands:/srv/project/commands
volumes:
pg_data: {}
static_content: {}