Explicit solution of an optimal design problem with non-affine displacement boundary conditions