#Dagger Unusual Behaviour

1 messages ยท Page 1 of 1 (latest)

wise parrot
#

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

static iron
#

๐Ÿ‘‹ can you share your Dagger pipeline please?

wise parrot
static iron
#

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

wise parrot
#

@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?

static iron
#

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

wise parrot
#

Thanks @static iron will try it out and circle back here

wise parrot
#

@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

brisk fog
#

I'll try to repro the caching issue

static iron
#

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

wise parrot
#

@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

static iron
#

๐Ÿ‘‹ 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

wise parrot
#

Thanks @static iron will check and circle back here

static iron
#

๐Ÿ‘

wise parrot
#

@static iron so things work after the suggested changes but i have 2 questions

  1. why is my base image downloaded every time?
  2. how do i cache the part where cargo pulls down dependencies?
static iron
#

@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

wise parrot
#

@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

static iron
wise parrot
#

@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

static iron
wise parrot
#

@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

wise parrot
#

@static iron so caching is working fine, Thanks for all the help

#

1 final question how can i manually invalidate buildkit cache if required?

static iron