Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add manuals section about named contexts #21672

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

dvdksn
Copy link
Contributor

@dvdksn dvdksn commented Dec 19, 2024

Description

Adds a section on the build contexts page about named contexts.

Related issues or tickets

@dvdksn dvdksn requested a review from crazy-max as a code owner December 19, 2024 13:17
@dvdksn dvdksn requested review from tonistiigi and a team December 19, 2024 13:17
@github-actions github-actions bot added the area/build Relates to Dockerfiles or docker build command label Dec 19, 2024
@dvdksn dvdksn added status/review and removed area/build Relates to Dockerfiles or docker build command labels Dec 19, 2024
Copy link

netlify bot commented Dec 19, 2024

Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit b9a3f19
🔍 Latest deploy log https://app.netlify.com/sites/docsdocker/deploys/679757ebf36d67000832043a
😎 Deploy Preview https://deploy-preview-21672--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@crazy-max crazy-max added the area/build Relates to Dockerfiles or docker build command label Jan 9, 2025
Comment on lines +603 to +604
# syntax=docker/dockerfile:1
FROM buildbase
WORKDIR /app
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a nice pattern is to define src and docs as scratch otherwise it will not find the stage if no named context is defined:

Suggested change
# syntax=docker/dockerfile:1
FROM buildbase
WORKDIR /app
# syntax=docker/dockerfile:1
FROM scratch AS src
FROM scratch AS docs
FROM buildbase
WORKDIR /app

I wonder if src as named context is necessary though. I think we could just have docs one as named context that would run make manpages only if /app/docs folder has files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, personally. Defining named contexts as empty stages... it feels a bit like a hack? I guess this is useful mostly when named contexts can be considered "optional"? Maybe we should have a section dedicated to that instead.

My concern with showing this pattern in the "main" example is that people might think this is the required syntax (define as an empty stage in the Dockerfile, override it on the command line).

Copy link
Member

@crazy-max crazy-max Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should have a section dedicated to that instead.

Yes good point that could be another section

content/manuals/build/concepts/context.md Outdated Show resolved Hide resolved
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
@dvdksn dvdksn merged commit 5df76d0 into docker:main Jan 27, 2025
14 checks passed
@dvdksn dvdksn deleted the build-ctx-named branch January 27, 2025 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build Relates to Dockerfiles or docker build command status/review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add info about named build context
2 participants