hasura / gitkube

Build and deploy docker images to Kubernetes using git push
Apache License 2.0
3.81k stars 208 forks source link

Templating for git hooks #48

Open tirumaraiselvan opened 6 years ago

tirumaraiselvan commented 6 years ago

Currently, pre-receive hook is fixed: https://github.com/hasura/gitkube/blob/master/build/gitkubed/pre_receive.sh

We want to make it scriptable to enable : https://github.com/hasura/gitkube/issues/20

Each hook probably needs variables from the remote like DEPLOYMENTS, REGISTRY_PREFIX. For pre-receive, we are currently doing a moustache render during startup.

For giving same variables to each hook, we need to run a moustache render on each hook and then place it in the correct directory.

jsierles commented 6 years ago

Would this also allow something like using a secret as a Docker build argument? For example, now I need to pass a Github token to a Dockerfile for fetching Github repos during the build. I can get the secret into Gitkubed's environment, but I see there is no way to pass a build argument currently.

coco98 commented 6 years ago

@jsierles Yep. You can then load the build argument from the kubernetes environment

kubectl get secrets my-secrets -o json | jq -r '.data."githubToken"' | base64 --decode

and then pass that as a build-arg to the docker build command.

@tirumaraiselvan Does that make sense?

jsierles commented 6 years ago

Yeah sounds good. But this is still not done or on any WIP branch, correct? Is there an easy way to manually update the hook besides updating gitkube to support more docker build arguments and redeploying it?

tirumaraiselvan commented 6 years ago

Yes, this issue is to make available arbitrary params to the build environment which can then be used in custom hooks. Custom hooks is in a WIP branch although I haven't gotten around to parameterization part yet. For now, the easiest way is to keep the token in the Dockerfile. The harder way is to fork from master and build your own version of Gitkube.

tirumaraiselvan commented 6 years ago

@jsierles docker build args support is here https://github.com/hasura/gitkube/pull/64