is it possible to build a docker image locally? it...
# general
d
is it possible to build a docker image locally? it seems like im having a realy hard time making pulumi just building an image locally.
l
Yes. If you want to use the Docker provider, it is strongly recommended that you use v4 or later. It was greatly improved at that point.
d
i’m using docker build provider but it’s doesn’t seem to respect my local cache and it also doesn’t respect my tags
l
You're setting cacheFrom and cacheTo?
d
yea
docker build doesn't seem to be working all that great:
Copy code
const baseImage = new dockerbuild.Image("BaseImage", {
  context: { location: "../../" },
  dockerfile: { location: "../../Dockerfile" },
  tags: [`test:latest`],
  cacheTo: [
    { local: { dest: "../../.build-cache", mode: dockerbuild.CacheMode.Min } },
  ],
  cacheFrom: [{ local: { src: "../../.build-cache" } }],
  push: false,
  noCache: false,
});
1. tags don't name the docker image. it names the image moby/buildkit 2. you can't name the docker build itself. names it my github repo link 3. caching doesn't work completely. it builds up to a certain point:
COPY . .
and then it does the full build afterwards If i run everything through the cli it works though:
docker buildx build . --tag test:latest -f ./Dockerfile --cache-to type=local,dest=.build-cache --cache-from type=local,src=.build-cache --builder clever_morse
l
../..
is a very strange path to choose. Your Pulumi project is nested two levels down from your Dockerfile? Could there be a problem with that, because something (I don't know what, a temp file maybe) is being written into a directory inside the context, while the image is being created?
d
i just have the runner i another folder to my actual project but does docker build create a temp file? i’ll try to investigate that
l
I would change the directory layout. Either the docker context is within the project directory, or is a sibling. There are examples in the provider docs of both of these situations. Having the context be a parent directory is not in any example, so I'd try not doing that.
d
but idk y it wouldn’t work tho? like it builds perfectly fine with the right context it’s just the metadata is bad like the name tags it even says it built 25 days ago
l
But when you run it from the command line, you're using context
.
and docker file
./Dockerfile
. In your code, you're using
../../
and
../../Dockerfile
. That's a difference that worth eliminating, at least to test.
d
yea surprisingly that seemed to be the issue idk why that would happen but seems to have fixed it
im still kinda confused why that would happen tho
wait that doesn't fix the naming though
yea it seems like the functionality of pulumi is different from the cli