Gitlab-rails create blank project

I have Gitlab docker container, and want to create a new image that contains an initial group & project. I set these up using the code shown below. However, the project is not blank. Visiting it locally (http://localhost/group-name/project-name) Results in a webpage showing: " No repository. The repository for this project does not exist. This means you can not push code until you create an empty repository or import existing one."

Could someone explain a bit what’s going on behind the scenes, why this is happening, and how I can initialize a blank project using gitlab-rails. I suppose this has to do with creating an empty git repo on gitlab and binding it to the project somehow. Any help is much appreciated since there pretty much doesn’t exist any documentation on this.

user = User.find_by(username: 'root')
group = Group.create(
    name: 'group-name',
    path: 'group-name',
    owner_id: user.id
)
group.save!
project = Project.create(
    name: 'project-name',
    path: 'project-name',
    creator_id: user.id,
    namespace_id: group.id,
    visibility_level: 20, # public
)

I had the same problem and finally discovered the method that creates the repo:

$ project.create_repository