That's quite a surprise! You'll need to do some fine tuning to start out but I can help you get everything just right. I encourage you to read through the newbies guides and intro to lighting articles listed on the right side of the page for a general overview but I'll be happy to answer any specific questions you have.
I suggest moving him to the 40g tank from the start. The extra space will give him room to roam a bit but (more?) importantly, it will allow you to create a proper heat gradient which is necessary for their well being.
The basking light should be a bright white light such as a ZooMed Repti Basking spot lamp or a PAR38 halogen flood light (or similar BR40 etc) from the hardware store. It should produce a nice bright light along with heat. It should be set at a height (and be proper wattage) to achieve a good temperature gradient. This may take some trial and error with your setup but once you have it dialed in, it doesn't take much fussing. You want to shoot for about 100-110 on the basking surface with a gradient down to about 75-80 or so on the cool side of the tank. It's important to get reasonably accurate readings so I suggest getting either a digital thermometer with 2 probes (or 2 digital thermometers) so you can set one on the basking surface and one on the cool side to monitor the temps constantly. You can also use a temp gun like this
https://www.amazon.com/Nubee-Temperature-Non-contact-Infrared-Thermometer/dp/B00CVHIJDK Using an adjustable lamp stand to raise/lower the basking light or hooking it to a dimmer may be helpful to fine tune the temps as needed but try to get close to the right temps based on wattage first.
The next critical component is UVB. You'll want to get a good
UVB light. In a 40g breeder tank you'll probably want to invest in a T5 tube like this
http://www.lightyourreptiles.com/22-t-5-ho-fixture-high-output-with-arcadia-d3-12-ho-bulb/ It will produce great UVB output for well over a year and has optimal output at about 12-14'' above the basking area so it can sit right on top of the tank. If that's too expensive for now, I'd go with a ReptiSun 10.0 T8 18'' bulb along with an 18'' Zilla Slimline fixture. This combination is good but not as powerful so it should sit about 6-8'' above the basking area and be mounted inside the tank if possible. Remember to remove the clear plastic from in front of the bulb as that will intercept all of the UVB.
A young dragon will be eating mostly bugs for food so I'd pick up a bunch of crickets or some dubia roaches (you'll need a lot so it's best to buy in bulk online and set up a bin for them) and maybe some black soldier fly larvae to offer as staple bugs. Silk worms are also a good option to throw in the mix. I also suggest preparing a salad every day. He may ignore it for a while in favor of the protein he needs to grow but it's helpful for him to be familiar with salads. You can feed the extras to the bugs every night. This site has some good ideas for salad items
http://www.beautifuldragons.com/Nutrition.html
I know it's a lot of info to take in at once so please let me know if you have any specific questions and I'll do my best to help out so everything is just right for him. You can upload photos of your new buddy here
https://www.beardeddragon.org/useruploads/ and post them to your thread using the XIMG button when you reply if you wish.