Skip to content

Commit 8dc7176

Browse files
committed
feat: add dockerfile
1 parent 5f3c87e commit 8dc7176

File tree

4 files changed

+88
-12
lines changed

4 files changed

+88
-12
lines changed

.dockerignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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
26+
!**/.gitignore
27+
!.git/HEAD
28+
!.git/config
29+
!.git/packed-refs
30+
!.git/refs/heads/**

src/Usuarios.Api/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
2+
3+
# This stage is used when running from VS in fast mode (Default for Debug configuration)
4+
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
5+
USER $APP_UID
6+
WORKDIR /app
7+
EXPOSE 8080
8+
EXPOSE 8081
9+
10+
11+
# This stage is used to build the service project
12+
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
13+
ARG BUILD_CONFIGURATION=Release
14+
WORKDIR /src
15+
COPY ["src/Usuarios.Api/Usuarios.Api.csproj", "src/Usuarios.Api/"]
16+
COPY ["src/Usuarios.Adapters/Usuarios.Adapters.csproj", "src/Usuarios.Adapters/"]
17+
COPY ["src/Usuarios.Application/Usuarios.Application.csproj", "src/Usuarios.Application/"]
18+
COPY ["src/Usuarios.Domain/Usuarios.Domain.csproj", "src/Usuarios.Domain/"]
19+
RUN dotnet restore "./src/Usuarios.Api/Usuarios.Api.csproj"
20+
COPY . .
21+
WORKDIR "/src/src/Usuarios.Api"
22+
RUN dotnet build "./Usuarios.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
23+
24+
# This stage is used to publish the service project to be copied to the final stage
25+
FROM build AS publish
26+
ARG BUILD_CONFIGURATION=Release
27+
RUN dotnet publish "./Usuarios.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
28+
29+
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
30+
FROM base AS final
31+
WORKDIR /app
32+
COPY --from=publish /app/publish .
33+
ENTRYPOINT ["dotnet", "Usuarios.Api.dll"]
Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
1-
{
2-
"$schema": "https://json.schemastore.org/launchsettings.json",
1+
{
32
"profiles": {
43
"http": {
54
"commandName": "Project",
6-
"dotnetRunMessages": true,
7-
"launchBrowser": false,
8-
"applicationUrl": "http://localhost:5266",
95
"environmentVariables": {
106
"ASPNETCORE_ENVIRONMENT": "Development"
11-
}
7+
},
8+
"dotnetRunMessages": true,
9+
"applicationUrl": "http://localhost:5266"
1210
},
1311
"https": {
1412
"commandName": "Project",
15-
"dotnetRunMessages": true,
16-
"launchBrowser": false,
17-
"applicationUrl": "https://localhost:7257;http://localhost:5266",
1813
"environmentVariables": {
1914
"ASPNETCORE_ENVIRONMENT": "Development"
20-
}
15+
},
16+
"dotnetRunMessages": true,
17+
"applicationUrl": "https://localhost:7257;http://localhost:5266"
18+
},
19+
"Container (Dockerfile)": {
20+
"commandName": "Docker",
21+
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
22+
"environmentVariables": {
23+
"ASPNETCORE_HTTPS_PORTS": "8081",
24+
"ASPNETCORE_HTTP_PORTS": "8080"
25+
},
26+
"publishAllPorts": true,
27+
"useSSL": true
2128
}
22-
}
23-
}
29+
},
30+
"$schema": "https://json.schemastore.org/launchsettings.json"
31+
}

src/Usuarios.Api/Usuarios.Api.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
<TargetFramework>net10.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
7+
<ContainerRepository>canal-deploy</ContainerRepository>
8+
<UserSecretsId>f37df685-f024-46d8-be4d-fbf46c25d53f</UserSecretsId>
9+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
10+
<DockerfileContext>..\..</DockerfileContext>
711
</PropertyGroup>
812

913
<ItemGroup>
14+
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
1015
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.5" />
1116
</ItemGroup>
1217

0 commit comments

Comments
 (0)