Skip to content

Commit 06733f2

Browse files
authored
Merge pull request #7 from sipsorcery-org/aspnet-localfunction
Aspnet localfunction example
2 parents a977d57 + 102f5db commit 06733f2

File tree

10 files changed

+982
-2
lines changed

10 files changed

+982
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ Several sample applications demonstrating different scenarios are available in t
167167
- **LocalFunctions** – showcases the local function calling feature.
168168
- **GetPaid** – extends local functions to simulate payment requests.
169169
- **DependencyInjection** – illustrates using the library with .NET DI.
170-
- **BrowserBridge** – ASP.NET Core application bridging a browser WebRTC client to OpenAI.
170+
- **ASP.NET Get Started** – ASP.NET application bridging a browser WebRTC client to OpenAI.
171+
- **ASP.NET Local Function** – ASP.NET application that builds on the Get Started example and adds a local function to tailor OpenAI responses.
171172

172173
Each example folder contains its own README with usage instructions.
173174

examples/AspNetGetStarted/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ COPY [".", "."]
4747

4848
# Publish the application
4949
FROM build AS publish
50-
RUN dotnet publish "./BrowserBridge.csproj" -c $BUILD_CONFIGURATION -o /app/publish
50+
RUN dotnet publish "./AspNetGetStarted.csproj" -c $BUILD_CONFIGURATION -o /app/publish
5151

5252
# Stage 4: Final Image to Run the App
5353
FROM base AS final
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<LangVersion>12.0</LangVersion>
7+
<Nullable>enable</Nullable>
8+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
9+
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="LanguageExt.Core" Version="4.4.9" />
14+
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
15+
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
16+
<PackageReference Include="SIPSorcery.OpenAI.WebRTC" Version="8.0.4" />
17+
</ItemGroup>
18+
19+
<!--<ItemGroup>
20+
<ProjectReference Include="..\..\src\SIPSorcery.OpenAI.WebRTC.csproj" />
21+
</ItemGroup>-->
22+
23+
</Project>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Stage 1: Build FFmpeg Image
2+
FROM sipsorcery/ffmpegbuild:7.0 AS ffmpeg
3+
4+
# Stage 2: Base Image - Install FFmpeg dependencies (This will be cached)
5+
FROM ubuntu:24.04 AS base
6+
7+
ENV DEBIAN_FRONTEND=noninteractive
8+
9+
# Install the required libraries for FFmpeg in the final image (as root)
10+
RUN apt-get update && apt-get install -y \
11+
libdrm2 \
12+
libsdl2-2.0-0 \
13+
libsndio7.0 \
14+
libxvidcore4 \
15+
libxv1 \
16+
libass9 \
17+
libvpx-dev \
18+
libsdl2-dev \
19+
libx264-dev \
20+
libx265-dev \
21+
libopus-dev \
22+
libfreetype6-dev \
23+
libvorbis-dev \
24+
libxvidcore-dev \
25+
libavutil-dev \
26+
libssl-dev \
27+
libavdevice-dev \
28+
libfdk-aac-dev \
29+
aspnetcore-runtime-8.0 \
30+
&& rm -rf /var/lib/apt/lists/*
31+
32+
WORKDIR /app
33+
EXPOSE 8081
34+
35+
# Stage 3: Build .NET Application (Only rebuilds if source code changes)
36+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
37+
38+
ARG BUILD_CONFIGURATION=Release
39+
WORKDIR /src
40+
41+
# Add local NuGet source (replace with your actual package version)
42+
#RUN mkdir -p /local-nuget
43+
#COPY ./local-nuget/*.nupkg /local-nuget/
44+
#RUN dotnet nuget add source /local-nuget --name local
45+
46+
COPY [".", "."]
47+
48+
# Publish the application
49+
FROM build AS publish
50+
RUN dotnet publish "./AspNetLocalFunction.csproj" -c $BUILD_CONFIGURATION -o /app/publish
51+
52+
# Stage 4: Final Image to Run the App
53+
FROM base AS final
54+
55+
WORKDIR /app
56+
57+
# Copy the published app from the build image
58+
COPY --from=publish /app/publish .
59+
60+
# Copy FFmpeg binaries and libraries from the FFmpeg build image
61+
COPY --from=ffmpeg /usr/local/bin/ffmpeg /usr/local/bin/
62+
COPY --from=ffmpeg /usr/local/bin/ffprobe /usr/local/bin/
63+
COPY --from=ffmpeg /usr/local/lib/libavcodec.so.61.3.100 /usr/local/lib/
64+
COPY --from=ffmpeg /usr/local/lib/libavdevice.so.61.1.100 /usr/local/lib/
65+
COPY --from=ffmpeg /usr/local/lib/libavfilter.so.10.1.100 /usr/local/lib/
66+
COPY --from=ffmpeg /usr/local/lib/libavformat.so.61.1.100 /usr/local/lib/
67+
COPY --from=ffmpeg /usr/local/lib/libavutil.so.59.8.100 /usr/local/lib/
68+
COPY --from=ffmpeg /usr/local/lib/libpostproc.so.58.1.100 /usr/local/lib/
69+
COPY --from=ffmpeg /usr/local/lib/libswresample.so.5.1.100 /usr/local/lib/
70+
COPY --from=ffmpeg /usr/local/lib/libswscale.so.8.1.100 /usr/local/lib/
71+
72+
# Update library links
73+
RUN ldconfig
74+
75+
# Ensure FFmpeg is available in the PATH for your app
76+
ENV PATH="/usr/local/bin:${PATH}"
77+
78+
# Set entrypoint to run the .NET application
79+
ENTRYPOINT ["dotnet", "AspNetLocalFunction.dll"]

0 commit comments

Comments
 (0)