A variational approach to mean curvature flow with Dirichlet conditions