version: '3.9'

services:
  vaultwarden:
    image: vaultwarden/server:1.30.5
    environment:
      DOMAIN: https://vaultwarden.localhost
      SIGNUPS_ALLOWED: 'false'
      SMTP_HOST: smtp
      SMTP_FROM: noreply@local
      SMTP_PORT: 587
      SMTP_SECURITY: starttls
      SMTP_USERNAME_FILE: /run/secrets/smtp_user
      SMTP_PASSWORD_FILE: /run/secrets/smtp_pass
    secrets:
      - smtp_user
      - smtp_pass
    volumes:
      - vw_data:/data
    networks:
      - traefik-public
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.routers.vw.rule=Host(`vaultwarden.localhost`)
        - traefik.http.routers.vw.entrypoints=websecure
        - traefik.http.routers.vw.tls=true
        - traefik.http.services.vw.loadbalancer.server.port=80

volumes:
  vw_data:
    driver: local
    driver_opts:
      type: nfs
      o: addr=omv800.local,nolock,soft,rw
      device: :/export/vaultwarden/data

secrets:
  smtp_user:
    external: true
  smtp_pass:
    external: true

networks:
  traefik-public:
    external: true
