#Dockerfile for dagger pipelines

1 messages · Page 1 of 1 (latest)

lost zinc
#

Hey Team,

I'm building a gitlab ci based pipeline to execute the following sort of commands:

dagger run go ci/main.go lint
dagger run go ci/main.go test
...

Every time these execute, I'm seeing a go mod download run ever execute:

3: go run ci/main.go lint
go: downloading dagger.io/dagger v0.9.3
go: downloading github.com/joho/godotenv v1.5.1
...

To get around this, I'm looking to create a container that gitlab ci uses to execute:

FROM golang:1.21-alpine 

WORKDIR /go/src
ENV GOCACHE=/go/src/.cache
RUN mkdir -p /go/src
ADD go.mod  .
ADD go.sum .
RUN go mod download

However, when this is being run, I'm still seeing the go mod's being downloaded.

Any ideas on why this is happening / what I need to change?

Thanks

Dinesh

knotty siren
#

Hey Dinesh! Is that running locally in your machine?

lost zinc
#

Hey, no - it's running inside a k8s cluster

#

gitlab ci builds the dockerfile, pushes it up to the registry

#

gitlab ci then pulls that conatiner and execs dagger run within that container

#

Running each dagger run on my local machine doesn't show the same behaviour for downloading mods evey execute

knotty siren
#

Are you using a stateful or stateless runners?

lost zinc
#

stateless runners - each run is a new container

knotty siren
#

If runners are stateless, go dependencies will get downloaded each time unless you're using Dagger Cloud

lost zinc
#

my expectation is that the go cache from the container build is used

#

ah - so it's intentional that it won't use any cached modules?

knotty siren
#

Not sure I follow. When you start a new job in a stateless runner, that machine is empty, so you need a way to hydrate the cache

#

Same thing happens with Docker build

lost zinc
#

the new job runs from the pre-built container with the dockerfile in the original post

#

rather than a brand new empty container

#

I'm on calls for the next 2 1/2 hours, but happy to jump on a session and show you what i'm up too anytime after that 🙂

knotty siren
#

Oh, I see.. in that case it should work

#

Sure, ping me later and we can check it out

lost zinc
#

amazing - thanks 🙂

lost zinc
#

ok - this may be working as expected

The downloading logs I can see might be from the actual build!