Skip to content

Commit 7e03a3b

Browse files
committedMay 16, 2021
Add compatibility with docker
1 parent 4292743 commit 7e03a3b

File tree

4 files changed

+58
-8
lines changed

4 files changed

+58
-8
lines changed
 

‎.dockerignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.classpath
2+
**/.dockerignore
3+
**/.env
4+
**/.git
5+
**/.gitignore
6+
**/.project
7+
**/.settings
8+
**/.toolstarget
9+
**/.vs
10+
**/.vscode
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md

‎src/Api/Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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/aspnet:3.1 AS base
4+
WORKDIR /app
5+
EXPOSE 80
6+
EXPOSE 443
7+
8+
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
9+
WORKDIR /src
10+
COPY ["src/Api/PublicApi.csproj", "src/Api/"]
11+
COPY ["src/ApplicationCore/Application.csproj", "src/ApplicationCore/"]
12+
COPY ["src/Infraestructure/Infraestructure.csproj", "src/Infraestructure/"]
13+
COPY ["src/Domain/Domain.csproj", "src/Domain/"]
14+
RUN dotnet restore "src/Api/PublicApi.csproj"
15+
COPY . .
16+
WORKDIR "/src/src/Api"
17+
RUN dotnet build "PublicApi.csproj" -c Release -o /app/build
18+
19+
FROM build AS publish
20+
RUN dotnet publish "PublicApi.csproj" -c Release -o /app/publish
21+
22+
FROM base AS final
23+
WORKDIR /app
24+
COPY --from=publish /app/publish .
25+
ENTRYPOINT ["dotnet", "PublicApi.dll"]

‎src/Api/Properties/launchSettings.json

+5-8
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,12 @@
2323
},
2424
"applicationUrl": "https://localhost:5001;http://localhost:5000"
2525
},
26-
"WSL 2": {
27-
"commandName": "WSL2",
26+
"Docker": {
27+
"commandName": "Docker",
2828
"launchBrowser": true,
29-
"launchUrl": "https://localhost:5001",
30-
"environmentVariables": {
31-
"ASPNETCORE_URLS": "https://localhost:5001;http://localhost:5000",
32-
"ASPNETCORE_ENVIRONMENT": "Development"
33-
},
34-
"distributionName": ""
29+
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
30+
"publishAllPorts": true,
31+
"useSSL": true
3532
}
3633
}
3734
}

‎src/Api/PublicApi.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<UserSecretsId>69ebd34f-7e36-4c49-a7ed-aac7898c8c3f</UserSecretsId>
6+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
7+
<DockerfileContext>..\..</DockerfileContext>
68
</PropertyGroup>
79

810
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -13,6 +15,7 @@
1315
<ItemGroup>
1416
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
1517
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.17.0" />
18+
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.13" />
1619
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.1.4" />
1720
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.1.4" />
1821
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.1.4" />

0 commit comments

Comments
 (0)
Please sign in to comment.