Support pre-post hooks for build, deploy and sync #1441
Closed
Description
Hi, in my workflow, I need to run some commands before I run skaffold. In CI/CD, I wrapped skaffold in a script, but it's a pain for developers to remember to run a script before running skaffold run
or or for me to maintain a wrapping CLI (EDIT: and skaffold dev
skaffold dev
doesn't work, see use case below). The developer experience would be improved if skaffold supported pre-build/pre-deploy hooks (and post-build/post-deploy hooks).
Suggestion:
apiVersion: skaffold/v1...
kind: Config
hooks:
preBuild:
exec:
command: ["python", "my-pre-build-hook.py"]
postBuild:
exec:
command: ["./my-post-build-hook.sh"]
preDeploy:
exec:
command: ["terraform", ...]
postDeploy:
exec:
command: ["curl", ...]
...
Details on my use case:
- I have a Python monorepo of microservices and shared libraries. I don't want to use the root of the repo as a microservice's Dockerfile context, because of the performance hit (breaks caching, huge context to send to docker daemon or kaniko), so before I build a microservice image, I copy the required shared libraries temporarily in the microservice subfolder / Dockerfile context, and remove them afterward (Docker doesn't follow symlinks if you wonder).
- kustomize doesn't support build-time variables, so I generate overlays to label, prefix and change namespaces depending on, e.g., the pull request number or the developer name.