moved dockerfile to alpine, added some errors in music
This commit is contained in:
parent
71242d3e80
commit
9cd67a22c4
4 changed files with 24 additions and 13 deletions
30
Dockerfile
30
Dockerfile
|
@ -11,7 +11,7 @@ COPY src/EllieBot.Voice/*.csproj src/EllieBot.Voice/
|
||||||
COPY src/EllieBot.GrpcApiBase/*.csproj src/EllieBot.GrpcApiBase/
|
COPY src/EllieBot.GrpcApiBase/*.csproj src/EllieBot.GrpcApiBase/
|
||||||
|
|
||||||
# Restore the dependencies for the EllieBot project
|
# Restore the dependencies for the EllieBot project
|
||||||
RUN dotnet restore src/EllieBot/ -r linux-x64
|
RUN dotnet restore src/EllieBot/ -r linux-musl-x64
|
||||||
|
|
||||||
# Copy the rest of the source code
|
# Copy the rest of the source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
@ -20,30 +20,38 @@ COPY . .
|
||||||
WORKDIR /source/src/EllieBot
|
WORKDIR /source/src/EllieBot
|
||||||
|
|
||||||
# Build and publish the EllieBot project, then clean up unnecessary files
|
# Build and publish the EllieBot project, then clean up unnecessary files
|
||||||
RUN dotnet publish -c Release -o /app --self-contained -r linux-x64 --no-restore; \
|
RUN dotnet publish -c Release -o /app --self-contained -r linux-musl-x64 --no-restore; \
|
||||||
mv /app/data /app/data_init; \
|
mv /app/data /app/data_init; \
|
||||||
chmod +x /app/EllieBot
|
chmod +x /app/EllieBot
|
||||||
|
|
||||||
# Use the .NET 8.0 runtime as the base image for the final stage
|
# Use the .NET 8.0 runtime as the base image for the final stage
|
||||||
FROM debian:12.9-slim
|
FROM alpine:3.20
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Music dependencies
|
||||||
|
# python3 required for yt-dlp, ffmpeg for conversion
|
||||||
|
|
||||||
ADD --chmod=755 https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp /usr/local/bin/yt-dlp
|
ADD --chmod=755 https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp /usr/local/bin/yt-dlp
|
||||||
|
RUN apk add --no-cache ffmpeg python3 libsodium
|
||||||
|
|
||||||
# Create a new user, install dependencies, and set up sudoers file
|
# Required dependencies
|
||||||
RUN apt update; \
|
# libc6-compat is required for .NET 8.0
|
||||||
apt install -y --no-install-recommends \
|
# libstdc++ and libgcc are required for (.NET 8.0 ? or drawing?)
|
||||||
libicu-dev ca-certificates \
|
# icu-libs is required for C# globalization
|
||||||
ffmpeg python3; \
|
|
||||||
apt autoremove -y; \
|
|
||||||
apt clean -y;
|
|
||||||
|
|
||||||
RUN update-ca-certificates
|
RUN apk update; \
|
||||||
|
apk add --no-cache libstdc++ libgcc icu-libs libc6-compat \
|
||||||
|
&& rm -rf /var/cache/apk/*;
|
||||||
|
|
||||||
# Copy the built application and the entrypoint script from the build stage
|
# Copy the built application and the entrypoint script from the build stage
|
||||||
COPY --from=build /app ./
|
COPY --from=build /app ./
|
||||||
COPY docker-entrypoint.sh /usr/local/sbin/
|
COPY docker-entrypoint.sh /usr/local/sbin/
|
||||||
|
|
||||||
|
# TODO: is there a better way to link the libsodium.so?
|
||||||
|
# TODO: Temporary linking, needs a proper solution
|
||||||
|
RUN rm /app/data_init/lib/libsodium.so \
|
||||||
|
&& ln -s /usr/lib/libsodium.so.26 /app/data_init/lib/libsodium.so
|
||||||
|
|
||||||
# Define the data directory as a volume
|
# Define the data directory as a volume
|
||||||
VOLUME [ "/app/data" ]
|
VOLUME [ "/app/data" ]
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@ data_init="/app/data_init"
|
||||||
data="/app/data"
|
data="/app/data"
|
||||||
|
|
||||||
# Merge data_init into data without overwrites.
|
# Merge data_init into data without overwrites.
|
||||||
cp -R -n "$data_init/." "$data/"
|
# cp -R -n "$data_init/." "$data/"
|
||||||
|
cp -R "$data_init/." "$data/"
|
||||||
|
|
||||||
echo "Yt-dlp update"
|
echo "Yt-dlp update"
|
||||||
# TODO: Update yt-dlp. It should not crash the entrypoint if ca-certificates is not installed
|
# TODO: Update yt-dlp. It should not crash the entrypoint if ca-certificates is not installed
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace EllieBot.Voice
|
||||||
{
|
{
|
||||||
internal static unsafe class Sodium
|
internal static unsafe class Sodium
|
||||||
{
|
{
|
||||||
|
|
||||||
private const string SODIUM = "data/lib/libsodium";
|
private const string SODIUM = "data/lib/libsodium";
|
||||||
|
|
||||||
[DllImport(SODIUM, EntryPoint = "crypto_secretbox_easy", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(SODIUM, EntryPoint = "crypto_secretbox_easy", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
|
|
@ -41,8 +41,9 @@ public sealed class VoiceProxy : IVoiceProxy
|
||||||
vc.SendPcmFrame(gw, data, 0, length);
|
vc.SendPcmFrame(gw, data, 0, length);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Log.Error(ex, "Couldn't send pcm frame: {Message}", ex.Message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue