Why is the .platform.app.yaml file separate from the .platform folder?

Why do we have: .platform.* files and also a .platform folder?
I mean, why not everything in the same folder?

Because in multi-app projects, there are multiple .platform.app.yaml files one for each app, and the convention is that the .platform.app.yaml file is placed on the top-level directory of the respective application.

The files in .platform control the environment at a cluster level. They define what services should be in the cluster.

The .platform.app.yaml file defines the behavior of one single application container, with your custom code.

You can have multiple applications in the same project, with their own code, but having multiple directories each with their own .platform.app.yaml file.

Any directory that contains a .platform.app.yaml file becomes an application container, configured by that file. If there’s only one application then the degenerate case is to just make that the repository root, which is fine. To have multiple application containers, you would do something like:

/
  .platform/
    routes.yaml
    services.yaml
  app1/
      .platform.app.yaml
  app2/
      .platform.app.yaml

And then app and app2 would become entirely separate application containers with the code in those respective directories.

1 Like