I have a debian based custom base image, when I use it in a Dockerfile to build new images from it , everything works fine, but if i attempt to do the same using dagger, it errors with /usr/bin/apt-get: /usr/bin/apt-get: cannot execute binary file.
I've restarted docker but that does not help, any pointers/suggestions would be great
#Dagger Unusual Behaviour
1 messages ยท Page 1 of 1 (latest)
๐ can you share your Dagger pipeline please?
ok, I see what the problem is. Seems like your image has bash as entrypoint. So doing bash apt-get update -y is not a valid command.
If you change your Args like this: {"-c", "apt-get update -y"} that should work since the resulting command will be bash -c "apt-get update -y" which is valid
@static iron but in't an exec call doing what docker exec does, or i'm getting things wrong, also with your suggestion would i need to change the cargo build call as well?
Exec is the same thing as doing docker run with your image.
in your example, if you do docker run nv5quantumspatial/rust_base_w_gdal_dependencies:1.65 apt-get install -y it will not work because of what I mentioned before
Thanks @static iron will try it out and circle back here
@static iron things work with your suggestions, but now caching is not taking place since the entire pipeline is run every time any suggestions on this
I'll try to repro the caching issue
maybe because you're exporting something every time you build and then re mounting it causes the cache to be invalidated each time?
I'd exclude the target dir when doing the Directory in from the host
@static iron here is a twist in the tale, i modified my base image to include apt-get commands that i was performing in my main.go earlier, and also removed the entrypoint setting, so basically now my base image has no entrypoint when i run things using this new base image i get the error "process "/_shim cargo build --release --bin transaction-worker" did not complete successfully: exit code: 1", where as if i run
docker run -it -v ${PWD}/inSITEV2:/app -w /app nv5quantumspatial/rust_base_w_gdal_dependencies:1.65a cargo build --release --bin transaction-worker it works perfectly. What am i doing wrong?
Thank you for bearing/answering with /my questions
๐ let me check
builder = builder.Exec(dagger.ContainerExecOpts{
Args: []string{fmt.Sprintf("cargo build --release --bin %s", binary)},
})
I believe here's the problem @wise parrot . You need to change the fmt.Sprintf with []string{"cargo","build","--release", "--bin"}
Because fmt.Sprintf makes everything to be a single string and you need to pass a slice here
Thanks @static iron will check and circle back here
๐
@static iron so things work after the suggested changes but i have 2 questions
- why is my base image downloaded every time?
- how do i cache the part where cargo pulls down dependencies?
@wise parrot are you sure the image is being downloaded each time? Can you share a minimal reproducible example so I can test here?
regarding 2, that should be cached automatically
@static iron surprisingly things seem to be working now, which is strange since the src code has not changed , it's the same code that i've been playing with for days, only changes that have happened were in the main.go as per your observations but nothing else, could that result in the above 2 things, also is there a cache invalidation period in play
@wise parrot can you try removing the target folder locally and building again? Did you make any changes given my comment here? #1042795331584262144 message
@static iron in the latest main.go that i had attached yesterday i'm not exporting the target dir anymore, as per your comment i'm only listing it(s) conetnts thats it, attaching main.go again
got it. Is the cache being invalidated every time?
@static iron in my recent attempts at running main.go i.e. in the past 20-30 mins, the cache does not get invalidated, and every thing finishes in seconds on every consecutive run
i would refer to my previous comment that the src code has not changed, only superficial changes in main.go as suggested
@static iron so caching is working fine, Thanks for all the help
1 final question how can i manually invalidate buildkit cache if required?
yes, there's currently no "official" way of doing that but you can force cache invalidation by adding a random env variable before your steps.
Here's an example: #1042418867487645736 message