Skip to content

Commit 201b5c7

Browse files
committed
add docker supoort
1 parent 35ce3fd commit 201b5c7

File tree

6 files changed

+87
-7
lines changed

6 files changed

+87
-7
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

BasicClean.Api/BasicClean.Api.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
5+
<UserSecretsId>e8ca6096-a03b-41dd-9109-8344940c76af</UserSecretsId>
6+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
57
</PropertyGroup>
68

79
<ItemGroup>
810
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.9">
911
<PrivateAssets>all</PrivateAssets>
1012
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1113
</PackageReference>
14+
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
1215
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.6.3" />
1316
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.6.3" />
1417
</ItemGroup>

BasicClean.Api/Dockerfile

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

BasicClean.Api/Properties/launchSettings.json

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
{
1+
{
22
"iisSettings": {
3-
"windowsAuthentication": false,
4-
"anonymousAuthentication": true,
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
55
"iisExpress": {
66
"applicationUrl": "http://localhost:61500",
77
"sslPort": 44328
@@ -18,10 +18,17 @@
1818
"BasicClean.Api": {
1919
"commandName": "Project",
2020
"launchBrowser": true,
21-
"applicationUrl": "https://localhost:5001;http://localhost:5000",
2221
"environmentVariables": {
2322
"ASPNETCORE_ENVIRONMENT": "Development"
24-
}
23+
},
24+
"applicationUrl": "https://localhost:5001;http://localhost:5000"
25+
},
26+
"Docker": {
27+
"commandName": "Docker",
28+
"launchBrowser": true,
29+
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
30+
"publishAllPorts": true,
31+
"useSSL": true
2532
}
2633
}
27-
}
34+
}

BasicClean.Api/appsettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"ConnectionStrings": {
3-
"TodoDb": "Data Source=.; Connect Timeout=180; Initial Catalog=TodoDb;uid=sa;pwd=Asd123..;MultipleActiveResultSets=True"
3+
"TodoDb": "Server=tododb;Database=TodoDb;User Id=sa;Password=Asd123.."
44
},
55
"Logging": {
66
"LogLevel": {

docker-compose.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: '3.9'
2+
3+
services:
4+
tododb:
5+
image: mcr.microsoft.com/mssql/server
6+
container_name: tododb
7+
ports:
8+
- "1433:1433"
9+
environment:
10+
SA_PASSWORD: "Asd123.."
11+
ACCEPT_EULA: "Y"
12+
todo.api:
13+
image: ${DOCKER_REGISTERY-}todoapi
14+
depends_on:
15+
- tododb
16+
build:
17+
context: .
18+
dockerfile: BasicClean.Api/Dockerfile
19+
ports:
20+
- "8090:80"
21+
22+

0 commit comments

Comments
 (0)