Skip to content

Conversation

@avichalchum
Copy link
Contributor

@avichalchum avichalchum commented May 27, 2020

Adding an example for .Net Core docker files as consumed by build agents and recommended by Microsoft best practices.

Proposed changes

Changing .Net Core example documentation to add an example that includes best practices by Microsoft for CI builds.

Unreleased project version (optional)

Related issues (optional)

Adding an example for .Net Core docker files as consumed by build agents and recommended by Microsoft best practices.
@netlify
Copy link

netlify bot commented May 27, 2020

✔️ Deploy preview for docsdocker ready!

🔨 Explore the source changes: 45d4bb9

🔍 Inspect the deploy logs: https://app.netlify.com/sites/docsdocker/deploys/5fcf5f6d107c7c000786930c

😎 Browse the preview: https://deploy-preview-10902--docsdocker.netlify.app

@gtardif
Copy link
Contributor

gtardif commented Nov 19, 2020

Hi @avichalchum,

Thanks for your proposal. The Dockerfile you propose is indeed simpler, but it assumes the application is already build by some external tool.
For CI we definitely recommend to use the Dockerfile including build steps , so your build does not require additional tools to be installed, and is more easily reproduced.

The simpler Dockerfile you propose could make the dev feedback loop quicker, but if you want to use this after you build your app in Visual Studio, you might as well run the app directly from visual studio for the quickest dev feedback loop, no need for an additional Dockerfile for this purpose.

@avichalchum
Copy link
Contributor Author

Hi @gtardif ,

Thank you for your feedback. My proposal was more around the build once, reuse multiple places principal and not for faster dev feedback. You're right, for a faster dev feedback, Visual Studio would be the fastest.

But if the same code artifacts are being used by multiple docker files and especially if the code build takes a long time (assuming greater than 15 minutes), then rather than build it for each dockerfile every time, the prod deploy CI tools will build the artifacts once and use those for the various dockerfiles.

Additionally, most production pipeline CI's could be running static/dynamic code analysis, vulnerability analysis, e.t.c. after the code is built by the pipeline, so building it again inside the dockerfile would then be redundant and add time.

I believe it is due to these reasons Microsoft also proposes a similar dockerfile: [https://docs.microsoft.com/en-us/dotnet/core/docker/build-container?tabs=windows#create-the-dockerfile](Microsoft dockerfile example).

Please note than I am proposing replacing the build steps inside a dockerfile to that outside. I am proposing providing both methods, a user who wishes to build the code inside the dockerfile can use method 1 and a user who is using it as a part of the CI can use method 2.

Copy link
Contributor

@gtardif gtardif left a comment

Choose a reason for hiding this comment

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

Hi @avichalchum,
Thanks, I see your point. We also see a lot of projects where it's better to build as much as possible inside containers, to reduce installed tooling on CI machines and make build more reproducible, make it easier to maintain build tool versions, etc.
I suggest we simply change the wording for your proposed method

Co-authored-by: Guillaume Tardif <guillaume.tardif@gmail.com>
@avichalchum
Copy link
Contributor Author

@gtardif thanks. I agree with your proposed wording and have accepted that.

gtardif
gtardif previously approved these changes Dec 4, 2020
@usha-mandya usha-mandya merged commit 19f2268 into docker:master Dec 8, 2020
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.

3 participants