V
V
vitaliyharchenko2019-12-22 22:50:02
Django
vitaliyharchenko, 2019-12-22 22:50:02

Why are there empty volumes in the docker-compose django caddy bundle?

I am raising django docker-compose server
for python
caddy for the postgres web server
for the database,
I want to mount static files from the django container to the caddy container. I'm trying to solve a problem named volume
when I enter the django container, I see all the static files, but when I access the caddy container, I find an empty directory. how to solve the problem?
docker-compose.yml

version: '3.7'

services:
  caddy:
    build:
      context: .
      dockerfile:  docker/production/caddy/Dockerfile
    image: quantgraph/caddy:development
    restart: always
    depends_on:
      - django
    volumes:
      - caddy:/home/caddy/.caddy
      - media:/var/www/static:ro
      - static:/var/www/media:ro
    env_file:
      - .envs/.caddy
    ports:
      - "80:80"
      - "443:443"

  django:
    build:
      context: ./python
      dockerfile: ../docker/production/django/Dockerfile
    image: quantgraph/django:development
    depends_on:
      - postgres
    volumes:
      - ./python:/code  # Project  code replace to /code into container
      - media:/code/files/media/
      - static:/code/files/static/
    stdin_open: true # stdin_open and tty will be useful for debugging
    tty: true
    restart: on-failure # So it can return when a SyntaxError breaks runserver
    env_file:
      - .envs/.postgres
    command: bash -c "sleep 5 && python3 manage.py migrate && python3 manage.py runserver_plus 0.0.0.0:5000 --settings=conf.settings.prod"

  postgres:
    image: postgres:10-alpine
    restart: always
    env_file:
      - .envs/.postgres
    volumes:
      - postgres_data:/var/lib/postgresql/data:rw

volumes:
  postgres_data:
  caddy:
  media:
  static:

Caddyfile
{$DOMAIN_NAME} {
    root /

    proxy / django:5000 {
        transparent

        except /static /media

        header_upstream Host {host}
        header_upstream X-Real-IP {remote}
        header_upstream X-Forwarded-Proto {scheme}
    }

    root /var/www

    log stdout
    errors stdout
    gzip
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question