version: '3'

services:
  nginx:
    image: nginx:1.16-alpine
    restart: unless-stopped
    volumes:
      - ./docker/conf/nginx:/etc/nginx/conf.d
      - ./docker/static_collected:/app/static_collected
      - ${MEDIA_DIR}:/app/data/media
    ports:
      - ${HTTP_PORT}:80
    #command: "/bin/sh -c 'while :; do sleep 1m & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
    depends_on:
      - web
    network_mode: bridge
    links:
      - web
  web:
    restart: unless-stopped
    build: "."
    links:
      - "db:postgres"
    volumes:
      - .:/app:rw
      - ${DATA_DIR}:/data:rw
      - ${STATIC_DIR}:/app/static_collected
      - ${MEDIA_DIR}:/app/data/media
    network_mode: bridge
    command: "/bin/sh -c '/app/wait-for-postgres.sh postgres /app/run.sh'"
    env_file:
      - ./.env
  db:
    restart: unless-stopped
    image: postgres:9.6-alpine
    env_file:
      - ./.env-db
    volumes:
      - ${POSTGRES_DATA_DIR}:/var/lib/postgresql/data:rw
    network_mode: bridge
