version: '2'
services:
  db:
    restart: always
    image: postgres:9.5
    volumes:
      - postgresql:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: 'postgres'
      POSTGRES_USER: 'postgres'
      POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
  backend:
    restart: always
    image: lesspass/backend:latest
    expose:
      - '8000'
    volumes:
      - www:/backend/www
    links:
      - db
    env_file:
      - .env
    environment:
      DATABASE_ENGINE: 'django.db.backends.postgresql'
      DATABASE_NAME: 'postgres'
      DATABASE_USER: 'postgres'
      DATABASE_HOST: 'db'
      DATABASE_PORT: '5432'
  frontend:
    restart: always
    image: lesspass/frontend:latest
  nginx:
    restart: always
    image: lesspass/nginx:letsencrypt
    ports:
      - '80:80'
      - '443:443'
    volumes_from:
      - backend
    volumes:
      - ./letsencrypt:/etc/letsencrypt
    links:
      - backend
      - frontend
    environment:
      - DOMAIN=${DOMAIN}
volumes:
  postgresql:
  www:
