  In this paper we prove a $C^{1,\alpha}$ regularity result in dimension two
for almost-minimizers of the constrained one-phase Alt-Caffarelli and the
two-phase Alt-Caffarelli-Friedman functionals for an energy with variable
coefficients. As a consequence, we deduce the complete regularity of solutions
of a multiphase shape optimization problem for the first eigenvalue of the
Dirichlet-Laplacian up to the fixed boundary. One of the main ingredient is a
new application of the epiperimetric-inequality of Spolaor-Velichkov [CPAM,
2018] up to the boundary. While the framework that leads to this application is
valid in every dimension, the epiperimetric inequality is known only in
dimension two, thus the restriction on the dimension.
