Skip to content

Commit

Permalink
feat: add Dockerfile to adaptive hls demo
Browse files Browse the repository at this point in the history
  • Loading branch information
josephnhtam committed Jun 8, 2024
1 parent 5f1330f commit 8e6f195
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
29 changes: 29 additions & 0 deletions samples/LiveStreamingServerNet.AdaptiveHlsDemo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
RUN apt-get update && apt-get install -y ffmpeg
USER app
WORKDIR /app
EXPOSE 80
EXPOSE 1935

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["samples/LiveStreamingServerNet.AdaptiveHlsDemo/LiveStreamingServerNet.AdaptiveHlsDemo.csproj", "samples/LiveStreamingServerNet.AdaptiveHlsDemo/"]
COPY ["src/LiveStreamingServerNet.StreamProcessor/LiveStreamingServerNet.StreamProcessor.csproj", "src/LiveStreamingServerNet.StreamProcessor/"]
COPY ["src/LiveStreamingServerNet.Rtmp/LiveStreamingServerNet.Rtmp.csproj", "src/LiveStreamingServerNet.Rtmp/"]
COPY ["src/LiveStreamingServerNet.Networking/LiveStreamingServerNet.Networking.csproj", "src/LiveStreamingServerNet.Networking/"]
COPY ["src/LiveStreamingServerNet.Utilities/LiveStreamingServerNet.Utilities.csproj", "src/LiveStreamingServerNet.Utilities/"]
COPY ["src/LiveStreamingServerNet/LiveStreamingServerNet.csproj", "src/LiveStreamingServerNet/"]
RUN dotnet restore "./samples/LiveStreamingServerNet.AdaptiveHlsDemo/LiveStreamingServerNet.AdaptiveHlsDemo.csproj"
COPY . .
WORKDIR "/src/samples/LiveStreamingServerNet.AdaptiveHlsDemo"
RUN dotnet build "./LiveStreamingServerNet.AdaptiveHlsDemo.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./LiveStreamingServerNet.AdaptiveHlsDemo.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "LiveStreamingServerNet.AdaptiveHlsDemo.dll"]
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<ServerGarbageCollection>false</ServerGarbageCollection>
<UserSecretsId>6f914df4-156f-4eba-b3e1-103c8c05e472</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
<DockerfileRunArguments>-p 1935:1935 -p 8080:80</DockerfileRunArguments>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

Expand Down
11 changes: 11 additions & 0 deletions samples/LiveStreamingServerNet.AdaptiveHlsDemo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
IMG ?= live-streaming-server-net-adaptive-hls-demo
PORT ?= 8080
RTMP_PORT ?= 1935

.PHONY: build
build:
docker build -t $(IMG) -f ./Dockerfile ../../

.PHONY: run
run:
docker run -p $(PORT):80 -p $(RTMP_PORT):1935 -d $(IMG)
2 changes: 0 additions & 2 deletions samples/LiveStreamingServerNet.AdaptiveHlsDemo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ private static ILiveStreamingServer CreateLiveStreamingServer(string transmuxerO
return LiveStreamingServerBuilder.Create()
.ConfigureRtmpServer(options => options
.Configure(options => options.EnableGopCaching = false)
.AddVideoCodecFilter(builder => builder.Include(VideoCodec.AVC))
.AddAudioCodecFilter(builder => builder.Include(AudioCodec.AAC))
.AddStreamProcessor(options =>
{
options.AddStreamProcessorEventHandler(svc =>
Expand Down

0 comments on commit 8e6f195

Please sign in to comment.