Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Adding sampl code for episode 10 - docker
- Loading branch information
1 parent
51e7657
commit 191ed3a
Showing
11 changed files
with
279 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.dockerignore | ||
.env | ||
.git | ||
.gitignore | ||
.vs | ||
.vscode | ||
docker-compose.yml | ||
docker-compose.*.yml | ||
*/bin | ||
*/obj | ||
!obj/Docker/publish/* | ||
!obj/Docker/empty/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<DockerComposeProjectPath>..\..\docker-compose.dcproj</DockerComposeProjectPath> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="wwwroot\" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<MicrosoftNETPlatformLibrary>Microsoft.NETCore.App</MicrosoftNETPlatformLibrary> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0-preview1-final" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
#Sample 1 - build on dev. machine, run within a container | ||
#FROM microsoft/aspnetcore-build:2.0 AS final | ||
#WORKDIR /app | ||
#COPY /WebApplication5/bin/Debug/netcoreapp2.0 . | ||
|
||
|
||
#Sample 2 - build on dev. machine, run within a container, runtime image | ||
#FROM microsoft/aspnetcore:2.0 AS final | ||
#WORKDIR /app | ||
#COPY /WebApplication5/bin/Debug/netcoreapp2.0 . | ||
|
||
|
||
FROM microsoft/aspnetcore:2.0 AS base | ||
WORKDIR /app | ||
EXPOSE 80 | ||
|
||
#Sample 3 - build in a container, run in another container | ||
#FROM microsoft/aspnetcore-build:2.0 AS build | ||
#WORKDIR /src | ||
#COPY *.sln ./ | ||
#COPY 10_AspNetCoreDocker/DockerSample/DockerSample.csproj 10_AspNetCoreDocker/DockerSample/ | ||
#RUN dotnet restore | ||
#COPY . . | ||
#WORKDIR /src/10_AspNetCoreDocker/DockerSample | ||
#RUN dotnet build -c Release -o /app | ||
# | ||
#FROM build AS publish | ||
#RUN dotnet publish -c Release -o /app | ||
# | ||
#FROM base AS final | ||
#WORKDIR /app | ||
#COPY --from=publish /app . | ||
#ENTRYPOINT ["dotnet", "DockerSample.dll"] | ||
|
||
|
||
#Sample 4, build in a container, run in another container, .NET Core 2.1 with Aline Linux | ||
FROM microsoft/dotnet:2.1-runtime-alpine AS base | ||
WORKDIR /app | ||
EXPOSE 80 | ||
|
||
FROM microsoft/dotnet:2.1-sdk-alpine AS build | ||
WORKDIR /src | ||
#COPY *.sln ./ | ||
COPY DockerSample.csproj DockerSample/ | ||
#RUN dotnet restore | ||
COPY . . | ||
WORKDIR . | ||
RUN dotnet build -c Release -o /app | ||
|
||
FROM build AS publish | ||
RUN dotnet publish -c Release -o /l/linux -r linux-x64 | ||
RUN dotnet publish -c Release -o /app | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /l/linux/libuv.so . | ||
COPY --from=publish /app . | ||
ENTRYPOINT ["dotnet", "DockerSample.dll"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace DockerSample | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
BuildWebHost(args).Run(); | ||
} | ||
|
||
public static IWebHost BuildWebHost(string[] args) => | ||
WebHost.CreateDefaultBuilder(args) | ||
.UseStartup<Startup>() | ||
.UseUrls("http://+:5000/") | ||
.Build(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
10_AspNetCoreDocker/DockerSample/Properties/launchSettings.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:50981/", | ||
"sslPort": 0 | ||
} | ||
}, | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"DockerSample": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"applicationUrl": "http://localhost:50982/" | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace DockerSample | ||
{ | ||
public class Startup | ||
{ | ||
// This method gets called by the runtime. Use this method to add services to the container. | ||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
} | ||
|
||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | ||
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | ||
{ | ||
if (env.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
|
||
app.Run(async (context) => | ||
{ | ||
await context.Response.WriteAsync("Hello World!"); | ||
}); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: '3' | ||
|
||
services: | ||
ci-build: | ||
image: microsoft/aspnetcore-build:1.0-2.0 | ||
volumes: | ||
- .:/src | ||
working_dir: /src | ||
command: /bin/bash -c "dotnet restore ./DotNetConceptOfTheWeek.sln && dotnet publish ./DotNetConceptOfTheWeek.sln -c Release -o ./obj/Docker/publish" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk"> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectVersion>2.0</ProjectVersion> | ||
<DockerTargetOS>Linux</DockerTargetOS> | ||
<ProjectGuid>61be99ce-ed87-4822-887f-72e8d7645911</ProjectGuid> | ||
<DockerLaunchBrowser>True</DockerLaunchBrowser> | ||
<DockerServiceUrl>http://localhost:{ServicePort}</DockerServiceUrl> | ||
<DockerServiceName>dockersample</DockerServiceName> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Include="docker-compose.override.yml"> | ||
<DependentUpon>docker-compose.yml</DependentUpon> | ||
</None> | ||
<None Include="docker-compose.yml" /> | ||
<None Include=".dockerignore" /> | ||
<None Include="docker-compose.ci.build.yml" /> | ||
</ItemGroup> | ||
</Project> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: '3' | ||
|
||
services: | ||
dockersample: | ||
environment: | ||
- ASPNETCORE_ENVIRONMENT=Development | ||
ports: | ||
- "80" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: '3' | ||
|
||
services: | ||
dockersample: | ||
image: dockersample | ||
build: | ||
context: . | ||
dockerfile: 10_AspNetCoreDocker/DockerSample/Dockerfile |