rancher / charts-build-scripts

Apache License 2.0
9 stars 32 forks source link

Switch to using Docker instead of using pulled-in binaries #99

Open aiyengar2 opened 1 year ago

aiyengar2 commented 1 year ago

Since charts-build-scripts directly exec the diff call, as seen here:

https://github.com/rancher/charts-build-scripts/blob/aa49bb9b0e39e8e7ea4119c8e379a1382126e8ba/pkg/diff/diff.go#L19

It doesn't have the same results on all machines since the version of diff used can be different.

To solve this, we should be using containerized rancher/charts-build-scripts runs instead of pulling in an appropriate charts-build-scripts binary to a machine (the current approach).

To do this, a couple of steps needs to be taken:

  1. We need to fix the Dockerfile to actually work: filed a PR in https://github.com/rancher/charts-build-scripts/pull/98 to resolve this
  2. Drone / GitHub workflows need to be set up to actually create the rancher/charts-build-scripts images and put them in a publicly accessible Docker repository
  3. make commands in https://github.com/rancher/charts-build-scripts/blob/master/templates/template/Makefile need to be modified to actually use this binary
  4. changes need to be made across relevant repos to use this appraoch

I pushed an image based on my current PR in https://github.com/rancher/charts-build-scripts/blob/master/templates/template/Makefile (based on v0.4.2) to my DockerHub fork for now, in case anyone wants to use it. To create your own, I ran REPO=arvindiyengar TAG=dev make build; REPO=arvindiyengar TAG=dev make package.

To run all the relevant commands in the containerized approach today, you can do that as follows:

# Assuming your current pwd is your charts directory (rancher/charts, rancher/rke2-charts, etc.)

PACKAGE=rancher-monitoring/rancher-monitoring

docker run -v $(pwd):/charts -w /charts -e USE_CACHE=1 -e PACKAGE=${PACKAGE} arvindiyengar/charts-build-scripts:dev charts-build-scripts prepare

docker run -v $(pwd):/charts -w /charts -e USE_CACHE=1 -e PACKAGE=${PACKAGE} arvindiyengar/charts-build-scripts:dev charts-build-scripts patch

docker run -v $(pwd):/charts -w /charts -e USE_CACHE=1 -e PACKAGE=${PACKAGE} arvindiyengar/charts-build-scripts:dev charts-build-scripts clean

docker run -v $(pwd):/charts -w /charts -e USE_CACHE=1 -e PACKAGE=${PACKAGE} arvindiyengar/charts-build-scripts:dev charts-build-scripts charts

docker run -v $(pwd):/charts -w /charts -e USE_CACHE=1 -e PACKAGE=${PACKAGE} arvindiyengar/charts-build-scripts:dev charts-build-scripts validate