chainguard-dev / apko

Build OCI images from APK packages directly without Dockerfile
https://apko.dev
Apache License 2.0
1.21k stars 125 forks source link

Avoid race when mutating annotations #1368

Closed jonjohnsonjr closed 4 weeks ago

jonjohnsonjr commented 4 weeks ago

This is a quick fix to a race condition we're hitting when building multi-arch images. The ImageConfiguration struct gets passed around by value, but the collections (e.g. annotations) don't get copied, so if multiple architectures attempt to set an annotation at the same time, we'll hit a race. This creates a defensive copy to avoid that.