Ask questionsCache miss when running in container

Consider this simple multi-stage build:

FROM debian:stretch-slim as build

RUN mkdir -p /build

RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    curl \
    && apt-get clean -y \
    && rm -rf /var/lib/apt/lists/* \
    && curl -fsSLO --compressed "$DENO_VERSION/deno_linux_x64.gz" \
    && gunzip -c deno_linux_x64.gz > /build/deno \
    && chmod u+x /build/deno \
    && rm deno_linux_x64.gz

COPY hello.ts /build
WORKDIR /build
RUN ./deno hello.ts

FROM debian:stretch-slim
COPY --from=build /build/deno /app/deno
COPY --from=build /build/deps /app/deps
COPY --from=build /build/gen /app/gen
COPY --from=build /build/hello.ts /app/
CMD ./deno hello.ts

The expectation is deno's compile cache will be hit when the resulting image is launched. However, this doesn't happen:

$ docker run hellodeno
Compiling /app/hello.ts
--- Hello from hello.ts ---

$ docker run hellodeno
Compiling /app/hello.ts
--- Hello from hello.ts ---
# RUN ./deno -D hello.ts

$ docker run hellodeno 2>&1 | grep -i cache
DEBUG RS - load_cache /app/gen/4e4584381ac19c16f9e1c6ae4db535f7521c99bd.js
DEBUG RS - load_cache /app/gen/790f0b07cf14ce8eda5eaab841b453acaf2e4da3.js
DEBUG JS - os.ts codeCache /app/hello.ts // tslint:disable-next-line:max-line-length
DEBUG RS - msg_from_js CodeCache sync true
DEBUG JS - os.ts codeCache /app/deps/ export function printHello(): void {
DEBUG RS - msg_from_js CodeCache sync true

^^ Not sure how to read that, some cache was loaded but not used?

If i exec (docker run -it image_name bash) inside the container, then the second time i run ./deno hello.ts, the cache is hit, so i guess DENO_DIR works.

There seems to be some other state outside deps and gen that i'm failing to copy over. Where's that state?

I see some calls to /dev/urandom with strace, if that's saved somewhere and then reused.. it could explain the cache miss.


Answer questions ry

Can you try printing the arguments of source_code_hash ?

Maybe this has something to do with a redirect happening during resolution.

If you could provide the source code you're trying to run that would help.