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

Don't rebuild everything after even slightest change #1672

Open
iirekm opened this issue Feb 25, 2025 · 2 comments
Open

Don't rebuild everything after even slightest change #1672

iirekm opened this issue Feb 25, 2025 · 2 comments

Comments

@iirekm
Copy link

iirekm commented Feb 25, 2025

The line COPY ./.devpod-internal/ /tmp/build-features/ in generated Dockerfile makes full rebuild even after tiniest changes in devcontainer.json. This is unprzctical. Why not add ./.devpod-internal/0 then ./.devpod-internal/1 and so on???

Enabling cache for apt, npm, pip, and similar commands (with RUN --mount) would also help a lot. Currently devpod image building is slow, so slow that it's almost useless to me and I have to switch to competition.

@bkneis
Copy link
Contributor

bkneis commented Mar 3, 2025

Hi @iirekm, I'm not sure why iterating over each ./.devpod-internal/X would help, this is the same as doing the former. Any change to .devcontainer.json will result in a different environment so the Dockerfile will need to be rebuilt.

You can use RUN --mount in your dockerfile, devpod supports this. Can you please clarify what you want devpod to change for this ticket?

@iirekm
Copy link
Author

iirekm commented Mar 3, 2025

Something like:

ADD install-feature-1.sh
RUN install-feature-1.sh
ADD install-feature-2.sh
RUN install-feature-2.sh
ADD install-feature-3.sh
RUN install-feature-3.sh

Is much faster than putting all at once, because if I reconfigure only feature 3, only the last layer has to be rebuilt. Most developers expect that the most experimental things, that are most likely to change or be reconfigured soon, should be put at end of Dockerfile, the most stable or the biggest ones - at top of Dockerfile. The same should probably be true for features: [...]" in devcontainers.json (if I put one I'm not sure at the end, I would expect it to rebuild fast).
With current approach all layers have to be rebuilt, no matter whether I change 1st or last feature, and some developer's tools (e.g. Rust, Android) do take some time to install.

Another easy to apply optimization technique is --mount to avoid re-downloading .deb, .whl and other files even if a layer has to be rebuilt, for example: RUN --mount=target=/var/cache/apt/archives,type=cache,sharing=locked apt-get install -y ... - why simply not add these to every RUN line above to cache downloads of all most common package managers (apt, pip, npm, rust, ...)? No matter what the install script contains, the downloads would be cached.

I know I can create own Dockerfiles (and I actually now do to address the performance issues above), but this requires lots of copy and paste between projects. Devcontainers features were created to improve reusability.

So to sum up, something like the following should help a lot:

ADD install-feature-1.sh
RUN --mounts for all popular package managers install-feature-1.sh
ADD install-feature-2.sh
RUN--mounts for all popular package managers install-feature-2.sh
ADD install-feature-3.sh
RUN --mounts for all popular package managers install-feature-3.sh

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

No branches or pull requests

2 participants