devfile / api

Kube-native API for cloud development workspaces specification
Apache License 2.0
237 stars 58 forks source link

extra files in nodejs stack #421

Closed kadel closed 2 weeks ago

kadel commented 3 years ago

Why nodejs stack (https://github.com/devfile/registry/tree/master/stacks/nodejs) has extra directories like deploy and build If it is not used anywhere?

This creates problems. If I have nodejs project that already has build/Dockerfile in it odo create nodejs will override my Dockerfile!

elsony commented 3 years ago

That stack was copied from https://github.com/odo-devfiles/registry/tree/master/devfiles/nodejs. I think that was created for the original odo deploy as the first attempt to provide the outer loop function in the prototype. In the original devfile in https://github.com/odo-devfiles/registry/blob/master/devfiles/nodejs/devfile.yaml, it has the metadata that can only be handled by odo:

  alpha.build-dockerfile: "https://raw.githubusercontent.com/odo-devfiles/registry/master/devfiles/nodejs/build/Dockerfile"
  alpha.deployment-manifest: "https://raw.githubusercontent.com/odo-devfiles/registry/master/devfiles/nodejs/deploy/deployment-manifest.yaml"

Since it does not conform with the spec, we currently removed those metadata from the version in the current repo but leave the files in the stack.

Regarding the conflict with the existing problem that you described, I wonder if odo needs to handle file conflict generically and prompt the user for action instead of just overwrites with the stack version. The reason is stack owners may decide to include any file as part of the stack, and those files can potentially conflict with files in the user's project. So the tools probably need to handle the conflict scenario anyway.

Even if we decide to not prompt the user, we can consider changing the default conflict-handling behaviour to preserve the existing user project files instead of overwriting them.

kadel commented 3 years ago

We should probably consider some naming standards for extra files. We can't ask users every time if the files should be overridden or not. Overriding project files with stack files is just bad behavior, and not overriding will most probably break the stack.

The current design where extra files can be in any directory is problematic. Stack creators will create directories like deploy, build, or even src. I can imagine that quite a few projects will already have directories with the same name as part of their repo.

What if I minimize the chances of this by saying that all extra files and dirs need to be in devfile or .devfile directory? This will make devfile stack a nice "package". It will always be .devfile.yaml with .devfile dir or devfile.yaml with devfile dir.

kadel commented 3 years ago

I will open PR to remove extra files from nodejs stack. They have no use right now.

elsony commented 3 years ago

+1 I think a dot folder (not sure if we want to call it .devfile, .stack, or something else) is a good suggestion. One of the goals that we have is to hide the complexity from the user. If the user is just a pure application developer and a stack consumer (no override), putting the devfile under a .devfile folder by default will help us to achieve that.

Note:

  1. If we do that, tools like odo may need to have extra logic to tolerate the existence of the devfile.yaml, e.g. make sure we don't add the .devfile folder when someone tries to do a create component on an existing project that already has a devfile.yaml on the root directory.
  2. We need to update our registry index build on the new directory structure.
yangcao77 commented 2 weeks ago

the issue has been fixed in https://github.com/devfile/registry/pull/21