Skip to content

Commit f7dd718

Browse files
committed
fix: Update Docker
1 parent 3c274ff commit f7dd718

4 files changed

Lines changed: 67 additions & 12 deletions

File tree

.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/OpenApi.Client.Mcp/Dockerfile

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
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.
22

3-
WORKDIR /src
4-
COPY . .
3+
# This stage is used when running from VS in fast mode (Default for Debug configuration)
4+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
5+
USER $APP_UID
6+
WORKDIR /app
7+
EXPOSE 8080
58

6-
RUN find . -type f -name 'appsettings.*.json' ! -name 'appsettings.json' -exec rm -f {} +
7-
RUN find . -name 'launchSettings.json' -exec rm -f {} +
89

9-
RUN dotnet publish "src/OpenApi.Client.Mcp/OpenApi.Client.Mcp.csproj" -c Release -o /app/ --nologo
10+
# This stage is used to build the service project
11+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
12+
ARG BUILD_CONFIGURATION=Release
13+
WORKDIR /src
14+
COPY ["Directory.Packages.props", "."]
15+
COPY ["Directory.Build.props", "."]
16+
COPY ["Directory.Build.targets", "."]
17+
COPY ["nuget.config", "."]
18+
COPY ["src/OpenApi.Client.Mcp/OpenApi.Client.Mcp.csproj", "src/OpenApi.Client.Mcp/"]
19+
COPY ["src/OpenApi.Client.SourceGenerators/OpenApi.Client.SourceGenerators.csproj", "src/OpenApi.Client.SourceGenerators/"]
20+
RUN dotnet restore "./src/OpenApi.Client.Mcp/OpenApi.Client.Mcp.csproj"
21+
COPY . .
22+
WORKDIR "/src/src/OpenApi.Client.Mcp"
23+
RUN dotnet build "./OpenApi.Client.Mcp.csproj" -c $BUILD_CONFIGURATION -o /app/build
1024

11-
FROM mcr.microsoft.com/dotnet/runtime:9.0 AS final
25+
# This stage is used to publish the service project to be copied to the final stage
26+
FROM build AS publish
27+
ARG BUILD_CONFIGURATION=Release
28+
RUN dotnet publish "./OpenApi.Client.Mcp.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
1229

30+
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
31+
FROM base AS final
1332
WORKDIR /app
14-
COPY --from=build /app/ .
15-
16-
ENTRYPOINT ["dotnet", "./OpenApi.Client.Mcp.dll"]
33+
COPY --from=publish /app/publish .
34+
ENTRYPOINT ["dotnet", "OpenApi.Client.Mcp.dll"]

src/OpenApi.Client.Mcp/OpenApi.Client.Mcp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<UserSecretsId>47a6b027-b381-4465-8c68-1f63fc721408</UserSecretsId>
55
<DockerfileContext>..\..</DockerfileContext>
66
<ContainerDevelopmentMode>Fast</ContainerDevelopmentMode>
7-
<DockerfileRunEnvironmentFiles>..\..\.env</DockerfileRunEnvironmentFiles>
7+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
88
</PropertyGroup>
99
<ItemGroup>
1010
<PackageReference Include="Microsoft.CodeAnalysis.Common" />

src/OpenApi.Client.Mcp/appsettings.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,12 @@
1111
"Microsoft.AspNetCore.Mvc.Infrastructure": "Warning"
1212
}
1313
},
14-
"AllowedHosts": "*"
14+
"AllowedHosts": "*",
15+
"Kestrel": {
16+
"Endpoints": {
17+
"Http": {
18+
"Url": "http://localhost:8080"
19+
}
20+
}
21+
}
1522
}

0 commit comments

Comments
 (0)