I made a PHP-based one a while ago before Duolingo offered Swahili. It probably needs a little upgrading, ha. A cool project and you can do it for most things. Oh plus it’s raw PHP so snappy as heck you youngins. https://github.com/ryanchausse/githeri
25 or so years ago, I learnt Esperanto (my first second language) by chatting on the Internet. I'd have two windows open - one with the IRC client, and the other with a terminal and a shell script that would grep a txt file with consistent formatting. "esp esperantoVerbPrefix/" or "esp noun," or "esp affix-" would typically return the correct result in a split second. Thanks to the simple grammar (that I had quickly memorized), I could hold conversations in near real time as a result.
I wish I could have learnt my other languages as easily.
Not self hosted but look at your local library, I am in the US and my library has Mango Languages for free, and Duolingo does not seem to be the recommended way to really learn a new language.