services:
  vaultwarden:
    image: ${VAULTWARDEN_IMAGE:-vaultwarden/server:latest}
    container_name: vaultwarden
    restart: unless-stopped
    environment:
      - DOMAIN=https://${VAULTWARDEN_DOMAIN}
      - SIGNUPS_ALLOWED=${SIGNUPS_ALLOWED:-true}
      - ADMIN_TOKEN=${ADMIN_TOKEN}
      - LOG_LEVEL=${LOG_LEVEL:-info}
      - TZ=Asia/Shanghai
      - SHOW_PASSWORD_HINT=${SHOW_PASSWORD_HINT:-false}
      - SENDS_ALLOWED=${SENDS_ALLOWED:-true}
    volumes:
      - ${VAULTWARDEN_DATA_DIR:-/var/lib/vaultwarden}:/data
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "127.0.0.1:${VAULTWARDEN_PORT:-8080}:80"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://127.0.0.1:80/alive"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 10s
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"
