GoogleContainerTools / GoogleContainerTools/skaffold
Custom builder should provide input for hash calculation for caching
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
###### Workaround: pass _dummy_ args to the build script that serve to differntiate cache calculation inputs on an otherwise equal custom build config (gotcha: the image name is not taken into account). Or — better — split build instructions into separate files and watch them separatly (with the added benefit that only one image cache is invalidated -as oposed to all images of this file)
---
- I delete all images from local docker store
- I invalidate the skaffold cache `rm ~/.skaffold/cache`
- Then I build with skaffold dev, I get this result in docker store:
```
ae-dir/web2ldap 19553c75108c03ec178835cf4edf464193af58453fe01435ecbd48cbcc6ba285 19553c75108c About a minute ago 182MB
ae-dir/web2ldap 65ab89b 19553c75108c About a minute ago 182MB
ae-dir/web-server c4bbb592d9ec914977a6e85995fc83fcad8b0123decf0affe7b409730a5f4d5c c4bbb592d9ec About a minute ago 77.9MB
ae-dir/web-server 65ab89b c4bbb592d9ec About a minute ago 77.9MB
```
```
Tags used in deployment:
- ae-dir/config-initializer -> ae-dir/config-initializer:b3b2a891f7bab54c5c41dd8dd6b1f6fdeff55af67081bc342c0b7acba12a48be
- ae-dir/openldap-ms -> ae-dir/openldap-ms:20d02c5b6af09e79f92857c49aa2cef8b7015c78a6520f1bb9da1bd74bf3a1f4
- ae-dir/web-server -> ae-dir/web-server:c4bbb592d9ec914977a6e85995fc83fcad8b0123decf0affe7b409730a5f4d5c
- ae-dir/web2ldap -> ae-dir/web2ldap:19553c75108c03ec178835cf4edf464193af58453fe01435ecbd48cbcc6ba285
Loading images into k3d cluster nodes...
- ae-dir/config-initializer:b3b2a891f7bab54c5c41dd8dd6b1f6fdeff55af67081bc342c0b7acba12a48be -> Loaded
- ae-dir/openldap-ms:20d02c5b6af09e79f92857c49aa2cef8b7015c78a6520f1bb9da1bd74bf3a1f4 -> Loaded
- ae-dir/web-server:c4bbb592d9ec914977a6e85995fc83fcad8b0123decf0affe7b409730a5f4d5c -> Loaded
- ae-dir/web2ldap:19553c75108c03ec178835cf4edf464193af58453fe01435ecbd48cbcc6ba285 -> Loaded
Images loaded in 57.452258464s
```
- Then I stop skaffold and a run `skaffold dev` again, I get this result in docker store:
```
ae-dir/web-server 19553c75108c03ec178835cf4edf464193af58453fe01435ecbd48cbcc6ba285 19553c75108c 17 minutes ago 182MB
ae-dir/web-server 65ab89b 19553c75108c 17 minutes ago 182MB
ae-dir/web2ldap 19553c75108c03ec178835cf4edf464193af58453fe01435ecbd48cbcc6ba285 19553c75108c 17 minutes ago 182MB
ae-dir/web2ldap 65ab89b 19553c75108c 17 minutes ago 182MB
```
```
Checking cache...
- ae-dir/config-initializer: Found Locally
- ae-dir/openldap-ms: Found Locally
- ae-dir/web-server: Found. Tagging
- ae-dir/web2ldap: Found Locally
Tags used in deployment:
- ae-dir/config-initializer -> ae-dir/config-initializer:b3b2a891f7bab54c5c41dd8dd6b1f6fdeff55af67081bc342c0b7acba12a48be
- ae-dir/openldap-ms -> ae-dir/openldap-ms:20d02c5b6af09e79f92857c49aa2cef8b7015c78a6520f1bb9da1bd74bf3a1f4
- ae-dir/web-server -> ae-dir/web-server:19553c75108c03ec178835cf4edf464193af58453fe01435ecbd48cbcc6ba285
- ae-dir/web2ldap -> ae-dir/web2ldap:19553c75108c03ec178835cf4edf464193af58453fe01435ecbd48cbcc6ba285
Loading images into k3d cluster nodes...
- ae-dir/config-initializer:b3b2a891f7bab54c5c41dd8dd6b1f6fdeff55af67081bc342c0b7acba12a48be -> Loaded
- ae-dir/openldap-ms:20d02c5b6af09e79f92857c49aa2cef8b7015c78a6520f1bb9da1bd74bf3a1f4 -> Loaded
- ae-dir/web-server:19553c75108c03ec178835cf4edf464193af58453fe01435ecbd48cbcc6ba285 -> Loaded
- ae-dir/web2ldap:19553c75108c03ec178835cf4edf464193af58453fe01435ecbd48cbcc6ba285 -> Loaded
```
That means skaffold retags an image to _the other_. Consequently _the other_ images gets pulled into the deployment and boom.
- I do a custom build:
```bash
set -e
repo=$(echo "$IMAGE" | cut -d':' -f 1)
tag=$(echo "$IMAGE" | cut -d':' -f 2)
out="$(mktemp -u)"
nix-build "$BUILD_CONTEXT/Nixfile.nix" -A "images.$repo" -o "$out" --arg image-tag "\"$tag\""
${docker}/bin/docker load -i $out
if $PUSH_IMAGE; then
${docker}/bin/docker push $IMAGE
fi
```
Contributor guide
Assessment
This issue has not been assessed yet.