Saute the onions in the olive oil over medium heat for 1 hour. There are a lot of onions, so use a very large non-stick skillet or a large Dutch oven. Do not cover - the onions will lose a lot of moisture and you want that to evaporate during the cooking process. Stir often!
Add the garlic and saute for 20 more minutes.
Reduce the heat to medium low and add the dried chili flakes, brown sugar, vinegar, and orange juice. Stir well to combine.
Continue to slow-cook the onions for an additional two hours. Stir often and watch the moisture level in the pan. If the onions begin to dry out, remove the pan from the heat immediately and begin the canning process. Otherwise, continue to cook until most of the moisture has evaporated and the onions turn a golden brown.
Pack the onions into sterilized mason jars. I like to use a metal funnel to avoid any of the onions coming into contact with the rim of the jar. This will help to create a better and safer seal. Fill the jar leaving at least 1/4-1/2 inch headspace. Remove the funnel and place a warmed, sterilized seal on the jar. Screw on the lid until just snug. Be careful! The jar will be hot! Use a kitchen towel to hold the jar in place as you screw on the lid.
Using a jar lifter, place the filled jars into the large pot of boiling water. Be sure the jars are not touching the bottom of the pot. This might cause the jar to break. I use a circular cooling rack that fits right into the bottom of my pot. (If you have a canning pot with a wire jar rack, then you won’t need to worry about this.)
Bring the pot back to a boil and allow the jars to remain in the boiling water for 20 minutes.
Carefully remove the jars and place on a kitchen towel where they will not be disturbed. As the jars cool, you’ll hear a popping sound. This is the hot liquid and air in the jar cooling down and contracting. This will create an air-tight seal and will allow you to store your onions for future consumption.
Makes five 250ml jars - serving size is 1 tablespoon.