In this paper we analyse the behaviour of a pile-up of vertically periodic walls of edge dislocations at an obstacle, represented by a locked dislocation wall. Starting from a continuum non-local energy $E_gamma$ modelling the interactions$-$at a typical length-scale of $1/gamma$$-$of the walls subjected to a constant shear stress, we derive a first-order approximation of the energy $E_gamma$ in powers of $1/gamma$ by $Gamma$-convergence, in the limit $gammatoinfty$. While the zero-order term in the expansion, the $Gamma$-limit of $E_gamma$, captures the `bulk profile of the density of dislocation walls in the pile-up domain, the first-order term in the expansion is a `boundary-layer energy that captures the profile of the density in the proximity of the lock. This study is a first step towards a rigorous understanding of the behaviour of dislocations at obstacles, defects, and grain boundaries.