  We study the formation of rocky planets by dry pebble accretion from
self-consistent dust-growth models. In particular, we aim at computing the
maximum core mass of a rocky planet that can sustain a thin H-He atmosphere to
account for the second peak of the Kepler's size distribution. We simulate
planetary growth by pebble accretion inside the ice line. The pebble flux is
computed self-consistently from dust growth by solving the advection-diffusion
equation for a representative dust size. Dust coagulation, drift, fragmentation
and sublimation at the water iceline are included. The disc evolution is
computed for $\alpha$-discs with photoevaporation from the central star. The
planets grow from a moon-mass embryo by silicate pebble accretion and gas
accretion. We analyse the effect of a different initial disc mass,
$\alpha$-viscosity, disc metallicity and embryo location. Finally, we compute
atmospheric mass-loss due to evaporation. We find that inside the ice line, the
fragmentation barrier determines the size of pebbles, which leads to different
planetary growth patterns for different disc viscosities. Within the iceline
the pebble isolation mass typically decays to values below 5 M$_{\oplus}$
within the first million years of disc evolution, limiting the core masses to
that value. After computing atmospheric-mass loss, we find that planets with
cores below $\sim$4 M$_{\oplus}$ get their atmospheres completely stripped, and
a few 4-5 M$_{\oplus}$ cores retain a thin atmosphere that places them in the
gap/second peak of the Kepler size distribution. Overall, we find that rocky
planets form only in low-viscosity discs ($\alpha \lesssim 10^{-4}$). When
$\alpha \geq 10^{-3}$, rocky objects do not grow beyond Mars-mass. The most
typical outcome of dry pebble accretion is terrestrial planets with masses
spanning from Mars to $\sim$4 M$_{\oplus}$.
