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

coder/kaniko: support caching ENV and ARG directives #254

Closed
johnstcn opened this issue Jun 28, 2024 · 1 comment · Fixed by coder/kaniko#17 or #273
Closed

coder/kaniko: support caching ENV and ARG directives #254

johnstcn opened this issue Jun 28, 2024 · 1 comment · Fixed by coder/kaniko#17 or #273
Assignees

Comments

@johnstcn
Copy link
Member

johnstcn commented Jun 28, 2024

Currently, when attempting to DoCacheProbe fails when encountering ENV directives:

#2: Using caching version of cmd: RUN cargo install exa bat ripgrep typos-cli watchexec-cli
#2: ENV CARGO_INSTALL_ROOT=/tmp/
error: get cached image: error probing build cache: uncached command *commands.EnvCommand encountered when probing cache

It looks like we need to implement the CachedExecuteCommand interface for both ENV and ARG commands:

To reproduce, here is a sample Dockerfile that fails to cache probe:

FROM alpine:latest
ENV FOO=hello
ARG BAR=world
RUN echo "$FOO $BAR" > /root/msg.txt

Alternatively, try to build the dogfood Dockerfile from coder/coder with ENVBUILDER_GET_CACHED_IMAGE=1 (assuming the image was previously built).

@coder-labeler coder-labeler bot added the bug label Jun 28, 2024
@johnstcn johnstcn changed the title coder/kaniko: support caching ENV directives coder/kaniko: support caching ENV and ARG directives Jul 5, 2024
@mafredri
Copy link
Member

As I was working on implementing tests for coder/kaniko#17 to fix this issue, I noticed we have another issue with multi-stage builds. COPY directives in multi-stage builds (COPY --from=first /a /b) rely on extraction to get the file hash. It makes sense but throws a few wrenches in our approach. Tracking the file hash across stages seems like a non-trivial thing to do. Without extraction, I think we'd still need to read the tar of the first stage to figure out the hash of the file to be copied.

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