In this paper we prove a C 1,α 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 [18] 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. 1 Remark 1.2. The Hölder continuity of the (exterior) normal vector n Ω is the best regularity result that one can expect. Indeed, recently Chang-Lara and Savin [10] showed that even for minimizers the regularity of the constrained free boundaries cannot exceed C 1, 1 /2 . Moreover, we notice that the result analogous to Theorem 1.1 was proved in any dimension in [10], by a viscosity approach, but only for minimizers of the functional J op .Analogously, we say that the nonnegative function u : B 2 → R is a almost-minimizer of the one-phase functional J op in B 2 , if u ∈ H 1 (B 2 ) and there are constants r 1 > 0, C 1 > 0 and δ 1 > 0 such that, for every x 0 ∈ B 1 ∩ ∂Ω u and r ∈ (0, r 1 ), we haveThe regularity of the unconstrained one-phase free boundary ∂Ω u follows directly by Theorem 1.1. For the sake of completeness, we give the precise statement in Corollary 1.3 below.Corollary 1.3 (Regularity of the unconstrained one-phase free boundaries). Let B 2 ⊂ R 2 and u : B 2 → R be a non-negative and Lipschitz continuous function. If u is a almost-minimizer of the functional J op in B 2 , then the free boundary B 1 ∩ ∂Ω u is locally the graph of a C 1,α function.