Skip to content

Commit 2ec2e27

Browse files
committed
feat(aspnetcoreclient): add docker support: AspNetCoreClient
1 parent 5ecc9b1 commit 2ec2e27

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

examples/AspNetCoreClient/AspNetCoreClient.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<AssemblyName>AspNetCoreClient</AssemblyName>
66
<RootNamespace>AspNetCoreClient</RootNamespace>
7+
<UserSecretsId>069babb5-5232-4d55-bcc0-973adf2bef35</UserSecretsId>
8+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
9+
<DockerfileContext>..\..</DockerfileContext>
710
</PropertyGroup>
811

912
<!-- 方便开发debug,与发布到nuget -->
@@ -13,6 +16,9 @@
1316
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
1417
<ProjectReference Include="..\..\src\SimCaptcha.AspNetCore\SimCaptcha.AspNetCore.csproj" />
1518
</ItemGroup>
19+
<ItemGroup>
20+
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
21+
</ItemGroup>
1622

1723

1824
</Project>

examples/AspNetCoreClient/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2+
3+
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
4+
WORKDIR /app
5+
EXPOSE 80
6+
EXPOSE 443
7+
8+
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
9+
WORKDIR /src
10+
COPY ["examples/ASPNETCoreClient/AspNetCoreClient.csproj", "examples/ASPNETCoreClient/"]
11+
COPY ["src/SimCaptcha.AspNetCore/SimCaptcha.AspNetCore.csproj", "src/SimCaptcha.AspNetCore/"]
12+
COPY ["src/SimCaptcha/SimCaptcha.csproj", "src/SimCaptcha/"]
13+
RUN dotnet restore "examples/ASPNETCoreClient/AspNetCoreClient.csproj"
14+
COPY . .
15+
WORKDIR "/src/examples/ASPNETCoreClient"
16+
RUN dotnet build "AspNetCoreClient.csproj" -c Release -o /app/build
17+
18+
FROM build AS publish
19+
RUN dotnet publish "AspNetCoreClient.csproj" -c Release -o /app/publish
20+
21+
FROM base AS final
22+
WORKDIR /app
23+
COPY --from=publish /app/publish .
24+
ENTRYPOINT ["dotnet", "AspNetCoreClient.dll"]
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
{
1+
{
22
"$schema": "http://json.schemastore.org/launchsettings.json",
33
"profiles": {
44
"AspNetCoreClient": {
55
"commandName": "Project",
66
"launchBrowser": true,
77
"launchUrl": "index.html",
8-
"applicationUrl": "https://localhost:5001;http://localhost:5002",
98
"environmentVariables": {
109
"ASPNETCORE_ENVIRONMENT": "Development"
11-
}
10+
},
11+
"applicationUrl": "https://localhost:5001;http://localhost:5002"
12+
},
13+
"Docker": {
14+
"commandName": "Docker",
15+
"launchBrowser": true,
16+
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/index.html",
17+
"publishAllPorts": true,
18+
"useSSL": true
1219
}
1320
}
14-
}
21+
}

0 commit comments

Comments
 (0)