-
Notifications
You must be signed in to change notification settings - Fork 370
Description
When you define a devcontainer with the following devcontainer.json
{
"build": {
"dockerfile": "Dockerfile"
}
}Then when you run devcontainer build this will translate to
docker buildx build --push --build-arg BUILDKIT_INLINE_CACHE=1 . . .However, if your devcontainer is defined as (example)
{
"image": "mcr.microsoft.com/devcontainers/python:3.12",
}Then the BUILDKIT_INLINE_CACHE=1 is not added to the build.
Additionally, I was unaware of this quirk and I had
- name: Build and push devcontainer cache
run: |
devcontainer build \
--workspace-folder . \
--image-name ghcr.io/azure-samples/xxxxt:latest \
--cache-from ghcr.io/azure-samples/xxxxx:latest \
--cache-to type=inline \
--pushWhen I switched over to the Dockerfile mechanism, you will then get a conflict where --cache-to type=inline and 'BUILDKIT_INLINE_CACHE=1' conflict with each other.
I would suggest that BUILDKIT_INLINE_CACHE=1 is added always when Buildkit is enabled. This would mean adding it to containerFeatures.ts - it is already added for singleContainer.ts and dockerCompose.ts to make everything consistent.
Then if someone adds --cache-to type=inline - this doesnt get added to prevent duplication. If they use other types, then this should be added to the command