Skip to content

Commit c1195c3

Browse files
authored
Merge pull request #95 from standleypg-dev/dockerfile_update
Optimize docker image footprint
2 parents 1c889ca + f4358be commit c1195c3

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

deployment/Dockerfile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ WORKDIR /deps
66
RUN apt update && apt install -y --no-install-recommends \
77
nodejs \
88
npm \
9-
ffmpeg \
109
libsodium-dev \
1110
libopus-dev \
12-
yt-dlp \
1311
wget \
14-
unzip \
15-
tzdata && \
16-
rm -rf /var/lib/apt/lists/* && \
17-
ln -sf /usr/share/zoneinfo/Asia/Singapore /etc/localtime
12+
unzip
1813

1914
RUN wget -O /tmp/libdave.zip \
2015
https://github.com/discord/libdave/releases/download/v1.1.1/cpp/libdave-Linux-X64-boringssl.zip && \
@@ -52,14 +47,18 @@ RUN dotnet publish "$PROJECT_PATH" \
5247
--self-contained false \
5348
--no-restore
5449

55-
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS final
50+
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
5651

5752
RUN apt update && apt install -y --no-install-recommends \
5853
ffmpeg \
5954
tzdata \
60-
yt-dlp && \
61-
rm -rf /var/lib/apt/lists/* && \
62-
ln -sf /usr/share/zoneinfo/Asia/Singapore /etc/localtime
55+
python3 \
56+
&& rm -rf /var/lib/apt/lists/* \
57+
&& ln -sf /usr/share/zoneinfo/Asia/Singapore /etc/localtime
58+
59+
# Install latest yt-dlp directly from GitHub releases
60+
ADD https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp /usr/local/bin/yt-dlp
61+
RUN chmod a+rx /usr/local/bin/yt-dlp
6362

6463
WORKDIR /app/run
6564

src/Infrastructure/Services/YoutubeService.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,18 @@ public async Task<string> GetAudioStreamUrlAsync(string url, CancellationToken c
7878
try
7979
{
8080
var ytdl = new YoutubeDL { YoutubeDLPath = "yt-dlp" };
81-
var result = await ytdl.RunVideoDataFetch(url);
82-
83-
result.EnsureSuccess();
81+
var overrideOptions = new YoutubeDLSharp.Options.OptionSet
82+
{
83+
Format = "bestaudio/best"
84+
};
85+
var result = await ytdl.RunVideoDataFetch(url, overrideOptions: overrideOptions);
86+
87+
if (!result.Success || result.Data?.Formats == null)
88+
{
89+
_logger.LogWarning("YT-DLP fetch failed for: {Url}. Errors: {Errors}", url,
90+
string.Join("; ", result.ErrorOutput ?? []));
91+
return (false, null);
92+
}
8493

8594
var httpsFormats = result.Data.Formats
8695
.Where(f => f.Protocol != "mhtml")
@@ -97,11 +106,6 @@ public async Task<string> GetAudioStreamUrlAsync(string url, CancellationToken c
97106
return (false, null);
98107
}
99108

100-
// Verify URL is accessible
101-
using var httpClient = new HttpClient();
102-
var response = await httpClient.GetAsync(bestAudio.Url);
103-
response.EnsureSuccessStatusCode();
104-
105109
return (true, bestAudio.Url);
106110
}
107111
catch (Exception ex)

src/Worker/Worker.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
DestinationFolder="$(OutputPath)"/>
3737
<Copy SourceFiles="/usr/lib/x86_64-linux-gnu/libopus.so"
3838
DestinationFolder="$(OutputPath)"/>
39-
<Copy SourceFiles="/usr/bin/yt-dlp"
40-
DestinationFolder="$(OutputPath)"/>
4139
</Target>
4240

4341
<PropertyGroup>
@@ -48,7 +46,6 @@
4846
<NativeLibs Include="/usr/lib/x86_64-linux-gnu/libsodium.so" />
4947
<NativeLibs Include="/usr/lib/x86_64-linux-gnu/libopus.so" />
5048
<NativeLibs Include="/usr/lib/libdave.so" />
51-
<NativeLibs Include="/usr/bin/yt-dlp" />
5249
</ItemGroup>
5350

5451
<!-- Copy after build -->

0 commit comments

Comments
 (0)