Skip to content

Commit

Permalink
Added docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
ardalis committed May 22, 2018
1 parent 7456c26 commit 9075221
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 5 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.dockerignore
.env
.git
.gitignore
.vs
.vscode
*/bin
*/obj
**/.toolstarget
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '3'

services:
eshopwebrazor:
image: eshopwebrazor
build:
context: .
dockerfile: src/WebRazorPages/Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "5107:5107"

eshopwebmvc:
image: eshopwebmvc
build:
context: .
dockerfile: src/Web/Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "5106:5106"

networks:
default:
external:
name: nat
19 changes: 19 additions & 0 deletions src/Web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/aspnetcore-build:2.1.300-preview1 AS build
RUN npm install -g bower@1.8.4
WORKDIR /src
COPY . .
WORKDIR /src/src/Web
RUN dotnet restore -nowarn:msb3202,nu1503
RUN dotnet build --no-restore -c Release -o /app

FROM build AS publish
RUN dotnet publish --no-restore -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Web.dll"]
1 change: 0 additions & 1 deletion src/Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public void Configure(IApplicationBuilder app,
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
ListAllRegisteredServices(app);
app.UseDatabaseErrorPage();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Web/Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0-rc1-final" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.0-rc1-final" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.1.0-preview1-final" /> </ItemGroup>
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Catalog\" />
<Folder Include="wwwroot\fonts\" />
Expand Down
19 changes: 19 additions & 0 deletions src/WebRazorPages/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/aspnetcore-build:2.1.300-preview1 AS build
RUN npm install -g bower@1.8.4
WORKDIR /src
COPY . .
WORKDIR /src/src/WebRazorPages
RUN dotnet restore -nowarn:msb3202,nu1503
RUN dotnet build --no-restore -c Release -o /app

FROM build AS publish
RUN dotnet publish --no-restore -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Microsoft.eShopWeb.RazorPages.dll"]
2 changes: 1 addition & 1 deletion src/WebRazorPages/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void Main(string[] args)

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseUrls("http://0.0.0.0:5106")
.UseUrls("http://0.0.0.0:5107")
.UseStartup<Startup>();
}
}
5 changes: 5 additions & 0 deletions src/WebRazorPages/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:28656/"
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://localhost:{ServicePort}"
}
}
}
1 change: 0 additions & 1 deletion src/WebRazorPages/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public void Configure(IApplicationBuilder app,
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
ListAllRegisteredServices(app);
app.UseDatabaseErrorPage();
}
Expand Down
3 changes: 2 additions & 1 deletion src/WebRazorPages/WebRazorPages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
<TargetFramework>netcoreapp2.1</TargetFramework>
<RootNamespace>Microsoft.eShopWeb.RazorPages</RootNamespace>
<AssemblyName>Microsoft.eShopWeb.RazorPages</AssemblyName>
<DockerTargetOS>Linux</DockerTargetOS>
<UserSecretsId>231ddc1b-6787-4704-a0c0-18df6a022660</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.1.0-preview1-final" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ApplicationCore\ApplicationCore.csproj" />
Expand Down

0 comments on commit 9075221

Please sign in to comment.