When used after verbs followed by the 接続助詞（せつぞくじょし） (conjunction particle) て, or nouns, the 副助詞（ふくじょし） (adverbial particle) ばかり
highlights that ‘nothing but (A) is being done’, or ‘only (A) exists’. In relation to verbs, てばかり is often followed by いる, as a modified version of the standard ている. However, adding いる is not a requirement, and the same nuance may be conveyed without it.
Our teacher does nothing but yell.
Recently, I've been eating nothing but junk, so my stomach is bulging out.
When a sentence consists of a part (A) and a part (B), ばかり will be followed by either で (with verbs or nouns), or いて (only with verbs). This is when ばかり appears directly before the sentence conjunction point, and other combinations are possible (such as ばかりだから).
My son who was born last month does nothing but cry, so I can't sleep.
All he does is work overtime everyday, and he won't help me with house chores.
When he opens his mouth, all he can do is complain, so just being with him is exhausting.
It should be noted that the で with ばかり here is not the particle で, but the 連用形（れんようけい） (conjunctive form) of the 助動詞（じょどうし） (auxiliary verb), だ
ばかり is rarely seen using kanji, but it originally comes from 許（ばか）り (sometimes 計（はか）る). This kanji means ‘to let off’, or ‘to let through’, and implies that (A) is the only thing that is being ‘permitted’ in a specific situation.