Cosmic-ray propagation with DRAGON2: I. numerical solver and astrophysical ingredients