#Docker caching issues with monorepo

10 messages · Page 1 of 1 (latest)

iron temple
#

Hi everyone!

I apology if this is not the right place to ask for Docker questions. Simply let me know, and I'll delete this post.

I moved some code to a monorepo. Everything works fine, except Docker acting weirdly

I have a structure like this one:

|
| - apps
| - - api
| - - frontend
|
| - packages
| - - types

I have a dockerfile which is reusable across apps, it looks like this:

COPY ./package.json ./pnpm-lock.yaml ./pnpm-workspace.yaml ./
COPY ./patches ./patches
COPY ./packages ./packages
COPY apps/${APP}/package.json ./apps/${APP}/
# Precache the deps, dirty workaround I've figured out to reuse the cache when deploying the app
RUN --mount=type=cache,target=${PNPM_HOME}/store pnpm fetch --filter "./apps/${APP}..." --filter "./packages/*..."
COPY ./apps/${APP}/ ./apps/${APP}
RUN --mount=type=cache,target=${PNPM_HOME}/store pnpm install --frozen-lockfile --filter "./apps/${APP}..." --filter "./packages/*..."
RUN pnpm --filter "./packages/*..." build

# Only export the package we're building
RUN --mount=type=cache,target=${PNPM_HOME}/store pnpm deploy --filter ./apps/${APP}... out

It works fine, but when I edit my types package, I have to delete the image from Docker desktop (or cli, both works), before starting the containers with the build flag. How can I avoid the manual image deletion process?
Any help is welcome.

Best regards

unborn pike
iron temple
unborn pike
#

np, hope it helps otherwise feel free to tell the result and we can dig further @iron temple

iron temple
#

right now i'm trying to see if anonymous volumes are causing my headache, i'll tell you if this works first

#

also, well i hate vmware :v

unborn pike
#

why?

#

i really liked that workstation is completely free rn. some years ago you had to use vmware player which was pain in the ass.

iron temple
#

mainly because i hate broadcom

iron temple
#

Alright the issue was because I had an anonymous volume pointing to node_modules, thanks for the help!