Skip to content

fix: preserve source paths in local build context#20

Open
ducminhle wants to merge 2 commits into
aspect-build:mainfrom
ducminhle:fix/buildx-context
Open

fix: preserve source paths in local build context#20
ducminhle wants to merge 2 commits into
aspect-build:mainfrom
ducminhle:fix/buildx-context

Conversation

@ducminhle

Copy link
Copy Markdown
Contributor

Previously buildx_context_local copied file inputs using basename, which flattened nested files into the context root. This broke Dockerfile COPY paths.

Copy files using their package-relative path so local build contexts keep the expected directory structure.

Example build container image from nodejs source:
Dockerfile

FROM node:24-alpine AS builder

WORKDIR /app

COPY --from=web_src package.json /app/package.json

RUN npm install

COPY --from=web_src . ./

RUN npm run build

FROM nginxinc/nginx-unprivileged:1.30-alpine3.23-slim as web

USER nginx

COPY --from=web_src nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf

COPY --from=builder /app/dist /usr/share/nginx/html

EXPOSE 8080

Changes are visible to end-users: yes/no

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: no

Test plan

  • Covered by existing test cases

Previously buildx_context_local copied file inputs using basename,
which flattened nested files into the context root. This broke Dockerfile
COPY paths such as nginx/conf.d/default.conf.

Copy files using their package-relative path so local build contexts keep
the expected directory structure.

Signed-off-by: ducminhle <minhducle.it@gmail.com>
@ducminhle

Copy link
Copy Markdown
Contributor Author

I noticed that _copy_sources_to_context_impl was reworked in #14. Did you have any particular ideas or design considerations in mind when you implemented it this way, or am I missing something, @njlr?

Signed-off-by: ducminhle <minhducle.it@gmail.com>
@njlr

njlr commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

I noticed that _copy_sources_to_context_impl was reworked in #14. Did you have any particular ideas or design considerations in mind when you implemented it this way, or am I missing something, @njlr?

Probably just an oversight on my part; your change seems like a good one. Now is a good time to decide this behaviour since the rules are still pre-release. 👍

I'm not a maintainer BTW

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants