#Docker and monorepo, cache issues

2 messages · Page 1 of 1 (latest)

dense cove
#

Hi everyone!

I'm sorry if this is not the right place to post. Please let me know and I'll delete this thread.

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 (only kept the deps part):

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. Any help would be welcome!

Best regards

golden gale
#

Why do you need to delete the image before starting the containers? how are you starting the containers (vscode extension, docker directly)? and what cache issues are you running into?