Models of planetary core growth by either planetesimal or pebble accretion are traditionally disconnected from the models of dust evolution and formation of the first gravitationally bound planetesimals. State-of-the-art models typically start with massive planetary cores already present. We aim to study the formation and growth of planetary cores in a pressure bump, motivated by the annular structures observed in protoplanetary disks, starting with submicron-sized dust grains. We connect the models of dust coagulation and drift, planetesimal formation in the streaming instability, gravitational interactions between planetesimals, pebble accretion, and planet migration into one uniform framework. We find that planetesimals forming early at the massive end of the size distribution grow quickly, predominantly by pebble accretion. These few massive bodies grow on timescales of ~ 100 000 years and stir the planetesimals that form later, preventing the emergence of further planetary cores. Additionally, a migration trap occurs, allowing for retention of the growing cores. Pressure bumps are favourable locations for the emergence and rapid growth of planetary cores by pebble accretion as the dust density and grain size are increased and the pebble accretion onset mass is reduced compared to a smooth-disc model.