version: '3'

services:
  app:
    build: .
    environment:
      DEBUG:
      INTERNAL_IPS:
      ALLOWED_HOSTS:
      DATABASE_URL:
      SECRET_KEY:
      EMAIL_URL:
      DJANGO_ADMINS:
      ORDER_FORM_SEND_EMAIL:
      ORDER_FORM_REPLY_TO_EMAIL:
      GANALYTICS_TRACKING_CODE:
    restart: always
    expose:
      - "8000"
    depends_on:
      - db
    volumes:
      - ./volumes/static:/opt/services/djangoapp/static
      - ./volumes/media:/opt/services/djangoapp/media

  nginx:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./nginx:/etc/nginx/conf.d
      - ./volumes/static:/opt/services/djangoapp/static
      - ./volumes/media:/opt/services/djangoapp/media
    depends_on:
      - app

  db:
    image: postgres:9.6
    restart: always
    environment:
      POSTGRES_PASSWORD:
      POSTGRES_USER:
    volumes:
      - "./volumes/db:/var/lib/postgresql/data"
      - "./volumes/pgdata:/tmp"
    ports:
      - "5432:5432"

version: '3'

services:
  app:
    build: .
    environment:
      DEBUG:
      INTERNAL_IPS:
      ALLOWED_HOSTS:
      DATABASE_URL:
      SECRET_KEY:
      EMAIL_URL:
      DJANGO_ADMINS:
      ORDER_FORM_SEND_EMAIL:
      ORDER_FORM_REPLY_TO_EMAIL:
      GANALYTICS_TRACKING_CODE:
    restart: always
    expose:
      - "8000"
    depends_on:
      - db
    volumes:
      - ./volumes/static:/opt/services/djangoapp/static
      - ./volumes/media:/opt/services/djangoapp/media

  nginx:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./nginx:/etc/nginx/conf.d
      - ./volumes/static:/opt/services/djangoapp/static
      - ./volumes/media:/opt/services/djangoapp/media
      - ./volumes/certbot:/etc/letsencrypt
    depends_on:
      - app

  db:
    image: postgres:9.6
    restart: always
    environment:
      POSTGRES_PASSWORD:
      POSTGRES_USER:
    volumes:
      - "./volumes/db:/var/lib/postgresql/data"
      - "./volumes/pgdata:/tmp"
    ports:
      - "5432:5432"

  certbot:
    depends_on:
      - nginx
    image: certbot/dns-digitalocean
    volumes:
      - ./volumes/certbot:/etc/letsencrypt
    command: "certonly
      -n
      --dns-digitalocean
      --dns-digitalocean-credentials /etc/letsencrypt/digitalocean.ini
      --dns-digitalocean-propagation-seconds 60
      --email ${CERTBOT_EMAIL}
      --agree-tos
      --no-eff-email
      --staging
      -d \"*.${CERTBOT_BASE_URL}\" -d ${CERTBOT_BASE_URL}"

Add certbot service to docker-compose
Add certbot service to docker-compose

This will request letsencrypt certificates using digitalocean dns plugin
