VIN will be 12V
and
I guess the current sourced from the regulator matters but I'm not
able to give an exact value at the moment so maybe take it 300mA
Worrying for a SOT223 5 volt linear regulator...
The LD1117S50TR is a SOT223 device and the data sheet specifies that it has a thermal resistance (junction to case) of 15°C/watt. But, the heat energy produced needs to be dissipated onto a large copper area and, if that was the top layer on a PCB having copper dimensions 50 mm x 50 mm, the extra thermal resistance to ambient would be approximately 38°C/watt. Figures taken from this calculator that I urge you to use to confirm what your likely value is.
I have just done a very quick calculation using the tool above so, it really is necessary for you to repeat this with more accurate figures that reproduces the copper size offered by the SOT223. However, I'm pretty sure you will be taken aback just how hot it will get.
If my figures are correct, the net thermal resistance from junction to ambient is 53°C/watt.
To produce an output of 300 mA, power dissipation will be 0.3 x (12 volts - 5 volts) = 2.1 watts
This means a temperature rise at the junction of 2.1 x 53° = 111.3°
In an ambient of 55° the junction would reach 166.3°
But the maximum junction temperature is only 125° for the device
And, localized heating raising the localized ambient temperature is not factored in yet
So, already I think you are in trouble (with a sizable 50 mm x 50 mm area of top copper) hence, I think it's not worth going further and calculating the other things until this is sorted out or abandoned.