devspace icon indicating copy to clipboard operation
devspace copied to clipboard

Improve documentation for pipeline functions

Open dhruvbaldawa opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? I want to understand how the --set, --set-string, --from and --from-file arguments work for build_images, create_deployments and start_dev pipeline functions. It would be great if you could add some documentation about it.

Which solution do you suggest? Add some examples about how to use them

Which alternative solutions exist?

Additional context

/kind feature

dhruvbaldawa avatar Aug 14 '22 04:08 dhruvbaldawa

@dhruvbaldawa thanks for the issue! Yes the pipeline functions need more examples and explanations! In general the flags are there to override certain parts of the config, so in build_images you can override parts of the images config with those:

images:
  myImage:
    dockerfile: ./Dockerfile

pipelines:
  build: |-
     echo "Welcome to your custom build pipeline!"

     # Exchange Dockerfile here (use --set-string if you want to force the field to be a string e.g. when setting labels to "true")
     build_images myImage --set dockerfile=./Dockerfile.dev
    
     # Use --from to create a new config based on an existing config
     build_images myOtherImage --from myImage --set context=../

     # Use --from-file when you want to load the config for the image from a file
     build_images myFileImage --from-file image.yaml

FabianKramm avatar Aug 15 '22 14:08 FabianKramm

@FabianKramm Thanks for the examples. I am working with many services, and each service has its own devspace.yaml file.

I find it tedious to do a cd service; devspace dev every time I have to work with a certain service. So, I wrote a wrapper script that can take multiple services as command line arguments and then merges their corresponding devspace.yaml file into a temporary devspace.yaml. Then I call the devspace --config temp-devspace.yaml command.

Example usage would look like this:

# Run `devspace dev` for `service-a/devspace.yaml` file
$ xsvc service-a dev

# Run `devspace dev` for a merged `{service-a,service-b}/devspace.yaml` file
$ xsvc service-a,service-b dev

My wrapper script currently merges all the images, deployments, dependencies, and profiles. I am curious to see how I can essentially utilize imports and pipelines to do the same thing in Devspace v6.

Do you have any thoughts about this?

dhruvbaldawa avatar Aug 15 '22 15:08 dhruvbaldawa

@dhruvbaldawa I see! You could use dependencies for that in your wrapper devspace.yaml with the newest beta version we just released:

version: v2beta1
name: test

dependencies:
  service-a:
    path: ./service-a/devspace.yaml
  service-b:
    path: ./service-b/devspace.yaml
  service-c:
    path: ./service-c/devspace.yaml
  service-d:
    path: ./service-d/devspace.yaml

pipelines:
  build: |-
    echo "$@" | xargs run_dependencies --pipeline build
  dev: |-
    echo "$@" | xargs run_dependencies --pipeline dev
  deploy: |-
    echo "$@" | xargs run_dependencies --pipeline deploy
  purge: |-
    echo "$@" | xargs run_dependencies --pipeline purge

Then you can simply use devspace dev service-a service-b or devspace deploy service-a -n my-namespace and it should work as expected.

FabianKramm avatar Aug 15 '22 17:08 FabianKramm