The problem you are looking for is called the "Nature vs nurture" debate. Lots of scientists have written lots of books and papers and done lots of studies on the subject. As you can see, the title of the debate already includes the two main concerning factors: nature (genes) and nurture (environment).
These of course each include a variety of ways in which they influence personality. Genes provide the biological basis for your personality, they determine how everything in your body works1. At the same time, these genes build a system that has a life of its own - your brain.
It consists of neurons, and nobody knows how personalitites comes about from them exactly but somehow they do. Neurons reshape all the time in ways that no other cells do. The connections between them, synapses, are formed, destroyed, reinforced or weakened all the time - in response to things that take effect on them, for example the things that you see and hear, smell, taste and feel. A very interesting subject in this field is the study of neuronal networks, giving some insight into how memory and learning may work.
But while this may seem like external factors must then be more important for personality, it depends on the setup provided by your genes how your neurons respond to certain influences - what concentrations of neurotransmitters they produce and secrete etc.
As you can see, the only thing that is really safe to say is that it is not "either or", both definitely play a role.
1But even the biological development of the body has non-genetic influences - at the moment I can think of epigenetic inheritance though this seems to be disputed (see comments). Apart from that as far as I know there are uterine influences on embryonic development. And then there are the more or less obvious external influences such as cutting things off before they develop.