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

Add instructions for using builder pattern #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions BuildOptimizedImages/src/Web/Dockerfile
@@ -0,0 +1,11 @@
FROM microsoft/aspnetcore-build:1.0.1

RUN mkdir /app
WORKDIR /app

ADD project.json .
RUN dotnet restore --no-cache
Copy link

Choose a reason for hiding this comment

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

Is there a compelling reason to do --no-cache here? You are slowing down the restore for no real gain.

Copy link
Author

@friism friism Feb 23, 2017

Choose a reason for hiding this comment

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

It's because I had misunderstood what the flag does: aspnet/MusicStore#713 (comment)

Copy link

Choose a reason for hiding this comment

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

Ah. That makes sense. Yeah, we probably should talk about clarifying the descriptions and such if it is still the same.


ADD . .
RUN dotnet publish --output /out/. --configuration Release
ADD Dockerfile.deploy /out/Dockerfile
7 changes: 7 additions & 0 deletions BuildOptimizedImages/src/Web/Dockerfile.deploy
@@ -0,0 +1,7 @@
FROM microsoft/dotnet:1.0.1-core

RUN mkdir /app
WORKDIR /app
ADD . .

CMD dotnet app.dll
3 changes: 1 addition & 2 deletions BuildOptimizedImages/src/Web/project.json
Expand Up @@ -57,7 +57,6 @@
},

"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
"prepublish": [ "bower install", "dotnet bundle" ]
}
}
15 changes: 15 additions & 0 deletions README.md
@@ -1,2 +1,17 @@
# BuildASPDotNetInAContainer
Sample used to build and test an ASP.NET Core Web app in a container

# Builder container pattern

Here's how to build the app in a container with the full .NET Core SDK, publish, export and then import in a smaller runtime container image:

1. `cd BuildOptimizedImages\src\Web`
2. `$image_id = docker build -q .`
3. `$container_id = docker create $image_id.split(":")[1]`
4. `$tmp_folder_name = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath() + [System.IO.Path]::GetRandomFileName())`
5. `mkdir $tmp_folder_name`
6. ``docker cp $container_id`:/out $tmp_folder_name``
7. `docker rm $container_id`
8. `docker build -t app $tmp_folder_name\out`
9. `Remove-Item -Recurse -Force $tmp_folder_name`
10. `docker run app`