Build only the subdirectory a service asks for - #21
Merged
Conversation
An image target that needs one subdirectory of the repository, such as an nginx service serving only the docroot, could express that only in its own Dockerfile, because --from and --to are pipeline-wide flags and cannot differ per service within one build. Take the copy paths the app build configuration now reports for each service and place them under the --from and --to roots. A service that reports no copy path builds the whole context exactly as before, and COPY_TO resolves the same way whichever Dockerfile wins, so a service-provided or author Dockerfile declaring ARG COPY_TO sees the same destination as the generated one. With this, a service that only needs part of the repository no longer has to ship a Dockerfile to say so.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--fromand--toare pipeline-wide flags: one value for every service in a build. A Drupal build needs.for php andweb/for nginx at the same time, which is why those nginx services still ship a Dockerfile just to writeCOPY ${COPY_FROM}/${DOCROOT_SUBDIR} ${COPY_TO}/${DOCROOT_SUBDIR}.The app build configuration now reports a per-service copy path. This places it under the
--from/--toroots, so the flags give the roots and the service gives the path within them.Behaviour
COPY_TOresolves the same way whichever Dockerfile wins, so a service-provided or author Dockerfile declaringARG COPY_TOsees the same destination as the generated one.., so a copy path alone is enough.With this, a service that needs only part of the repository no longer has to ship a Dockerfile to say so.
Validation
go build ./...andgo test ./cmd/... ./pkg/...pass. New test covers the join across default, explicit, absolute, nested and empty roots and subdirectories.Requires
The backend change that adds
copyFrom/copyToto the build configuration. Without it both fields are empty and every build behaves exactly as it does today.