Karosta served most of its existence as a military base, first built in 1890 for use by the Russian fleet under Tsar Alexander III. During the upheavals of the 20th century, the base first came under the control of independent Latvia, then the USSR, and the invading German army during World War II, again to the USSR for most of the 20th century, until Latvia regained its independence in 1991 (although Russian soldiers only left it in 1994).
The authorities changed, but the purpose of the institution remained the same: to hold prisoners, including revolutionaries, sailors and non-commissioned officers of the Russian Imperial Army, German deserters, enemies of the people from the Stalin era, as well as soldiers of the Soviet and Latvian armies.
Karosta Prison in Liepaja is the only military prison in Europe open to tourists. Built around 1900 for hospital needs, the building was never used for its original purpose. The facility was repurposed as a place for temporary disciplinary detention and was used as such until 1997.
Karosta is currently open to visitors, with guided tours available. The tours showcase the prison, allowing visitors to learn its history, see the prison and the solitary confinement cells, and hear interesting and even ghostly stories about life in the prison. The bravest have the opportunity to participate in the reality show "Behind Bars" or try to escape from locked rooms. And those who know no fear can spend a night in a prison cell. Karosta Prison has an information center "Karosta," a Soviet-era buffet, and a souvenir shop.
The last thing Karosta Prison offers is the chance to truly spend a night in a prison cell. As with the tours, there is a basic option that includes overnight stay on a prison bunk and meals, or an interactive option “Extreme Night,” which repeats the “Behind Bars” tour. This is a form of dark tourism; a night in prison is not for the faint-hearted — visitors must sign a release form confirming that they will be treated like prisoners, including verbal insults and physical exercises. You will sleep in a room almost completely replicating the design of a prison cell with iron doors and bars. You can eat what prisoners are accustomed to eating. They say ghosts haunt this place, cell doors slam by themselves, and sometimes the corridors echo with the clinking of chains. But this is not the fault of your “guards,” that is, the hotel hosts. You will be especially lucky (or unlucky?) if the ghost of a prisoner appears before you and silently stares into your eyes.

For many years, Karosta suffered significant neglect and is now a semi-abandoned area. Most of this district is covered with abandoned buildings overgrown with forest, giving it a somewhat eerie appearance. If you are a fan of abandoned areas, you could have a lot of fun exploring here.
Another main attraction of Karosta is the Northern Forts. Originally, they were part of the surrounding fortifications protecting the Karosta naval base in the late 19th and early 20th centuries. Today, the forts are in a state of disrepair but offer incredible views. What remains of the forts scattered along the coast north of Karosta is a series of crumbling concrete bunkers slowly collapsing into the Baltic Sea.
Sources:
https://karostascietums.lv/en/
https://militaryheritagetourism.info/en/military/sites/view/21?0
https://www.travelsewhere.net/karosta/