Add environment variables and set max_distance in environment files