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
Cache miss when running in container #1082
Comments
Also, is there a way to just bundle up everything a la Golang static builds? One static ELF binary with everything in so you can |
Any update on this would be appreciated. I'm running into the exact same issue. (cached source code is missed, and new hashes are generated for all sources. aka, all of DENO_DIR/gen is regenerated.) Looks like the method that generates the cache_key only takes 3 params: fn source_code_hash(
filename: &str,
source_code: &[u8],
version: &str,
) -> String {
let mut ctx = ring::digest::Context::new(&ring::digest::SHA1);
ctx.update(version.as_bytes());
ctx.update(filename.as_bytes());
ctx.update(source_code);
let digest = ctx.finish();
let mut out = String::new();
// TODO There must be a better way to do this...
for byte in digest.as_ref() {
write!(&mut out, "{:02x}", byte).unwrap();
}
out
} Now the question is, which one of the 3 is changing? |
Can you try printing the arguments of 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. |
@njbraun there were some changes to |
Unfortunately, it behaves the same for me, cache miss,
|
Thanks for checking, I'll try to debug the problem |
@snobu I've replicated your setup - the problem is FROM debian:stretch-slim as build
ENV DENO_VERSION 0.5.0
ENV DENO_DIR /denodir
RUN mkdir -p /build
WORKDIR /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 "https://github.com/denoland/deno/releases/download/v$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
ENTRYPOINT ["/build/deno", "run", "-D", "hello.ts"] Then: docker build -t hellodeno .
docker run -v `pwd`/container_cache:/denodir hellodeno Let me know if you need anymore info |
You can also put a I think a nice pattern for this is:
|
Also you're not forced to mount it to your machine but you can keep it in docker volumes. Check the doc: https://docs.docker.com/storage/volumes/ |
Thank you @bartlomieju. That actually makes perfect sense, somehow i completely forgot how containers work since i opened this issue. May i suggest an official Dockerfile example be added to the repo with a note on caching (persistent volume)? I'm sure there are others like me out there :) |
I pushed this deps.ts to my deno_docker example (deps are cached as a layer so don't need to be refetched + compiled unless deps.ts changes, this speeds up the Docker dev cycle significantly). |
I’d be happy to have a Dockerfile as long as it was exercised in CI. |
Providing a docker-compose would be great too with sharing of cache between containers. Like version: "3"
services:
deno2:
image: deno2
volumes:
- deno-cache:/cache/
ports:
- "8080:80"
deno1:
image: deno1
volumes:
- deno-cache:/cache/
ports:
- "8090:80"
volumes:
deno-cache: |
@zekth I guess that should work OOTB if you specify DENO_DIR? |
@ry I suspect you want these in a sep repo so that you can test images against release binaries (rather than generate your own). I think adding to CI would be kinda fiddly, if you wanted to keep the image small, as you wouldn't be able to cache layers... at least that's my understanding, perhaps there's an easy way that's also fast. |
You may have multiple cases. One is to mount your cache on your host another is to mount the cache in docker volumes. Really depends on the case / uses. It's the same has having In the case of your example you fetch only I can't be really sure about all the scenarios, i think it will be after several uses we will figure out what's the best solution. |
@zekth Let's move that discussion to https://github.com/hayd/deno_docker/issues/4 (or a new issue). I think your example could/would work already. |
Consider this simple multi-stage build:
The expectation is deno's compile cache will be hit when the resulting image is launched.
However, this doesn't happen:
^^ 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 guessDENO_DIR
works.There seems to be some other state outside
deps
andgen
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.The text was updated successfully, but these errors were encountered: