Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devcontainer build does not use docker build cache #313

Closed
cwharris opened this issue Dec 5, 2022 · 1 comment
Closed

devcontainer build does not use docker build cache #313

cwharris opened this issue Dec 5, 2022 · 1 comment

Comments

@cwharris
Copy link

cwharris commented Dec 5, 2022

devcontainer build chooses to use a different --build-context on each build, forcing Docker to build from scratch each time, even if only a single feature was modified.

$ devcontainer build ~/dev/project/.devcontainer/ --workspace-folder ~/dev/project/
[10 ms] @devcontainers/cli 0.25.2. Node.js v17.0.1. linux 5.10.0-1050-oem x64.
[12164 ms] Start: Run: docker buildx build
    --load \
    --build-context dev_containers_feature_content_source=/tmp/devcontainercli-charris/container-features/0.25.2-1670206334608 \
    --build-arg _DEV_CONTAINERS_BASE_IMAGE=ubuntu:focal \
    --build-arg _DEV_CONTAINERS_IMAGE_USER=root \
    --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp \
    --target dev_containers_target_stage
    -t vsc-project-de9db83a4d84fadc3ffbe532c095a7c7-features
    -f /tmp/devcontainercli-charris/container-features/0.25.2-1670206334608/Dockerfile.extended
    /tmp/devcontainercli-charris/empty-folder

I discovered this while working on a custom feature that depended on multiple time-consuming-to-build features, wasting several hours waiting on builds trying to figure out why no steps of the build were being cached.

This makes devcontainers impractical for me, since I need to develop quite a few features to support the work I'm doing. If each single character change to an install script causes an uncached build of the entire container, developing features becomes infeasible.

const tmpFolder: string = cliHost.path.join(await getCacheFolder(cliHost), 'container-features', `${version}-${Date.now()}`);

What happens if we just remove Date().now from tmpFolder name?

@chrmarti
Copy link
Contributor

chrmarti commented Dec 5, 2022

Not sure the new folder plays a role here. We are using a single layer for building the features which is tracked in #291. Continuing there. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants