Space to grow isn't a big issue here if we talking about 5kk people.
Heat dissipation in space is more issue here.
It needs something around 10kW plant spectrum light 24.7.365, space 50-100 square meters, volume 100-200 cubic meters per single person. Not super duper food for someone, kinda minimal setting.
The process is not much efficient and probably needs more energy.
To dissipate 10kW heat at 300K from the hull of the ship needs roughly 20 square meters.
For 5'000'000 peoples it has to be 100kk m2 surface of the hull, where heat dissipation is happening.
- sphere, radius 2900m, 20500 cubic meters volume per person.
- cube, side 4100m, 13800 cubic meters volume per person.
If they have good energy sources, like thermonuclear reactors or such, they can cool internal volume more efficient. 600K, 2 times higher is the temperature of the shell, 4 times less radius or edge of the cube, to irradiate the same amount of heat energy. It's may be a good idea to place reactor outside of the ship, this way it can work at a higher temperature.
The ratio of internal volume to the surface can be arbitrary, by scaling one of the axis, or changing form, like pencil-cylinder.
Plants do not need gravity to grow, not sure about all of them, but those which were tested in space. (I do not know is it important for trees, fruit trees or not - maybe not or not so much)
For 17 millions of people ship size is $\small \sqrt{17/5} \approx 1.84$ times bigger, and volume will be $\small (\sqrt{17/5})^3 \approx 6.27$ time more per person.
So as you may see, the bigger ship is, the less problem is the volume or internal surface.