elliebot/Dockerfile

60 lines
2.1 KiB
Text
Raw Normal View History

# Use the .NET 8.0 SDK as the base image for the build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
2024-06-18 23:48:54 +12:00
WORKDIR /source
# Copy the .csproj files for each project
2024-06-18 23:48:54 +12:00
COPY src/Ellie.Marmalade/*.csproj src/Ellie.Marmalade/
COPY src/EllieBot/*.csproj src/EllieBot/
COPY src/EllieBot.Coordinator/*.csproj src/EllieBot.Coordinator/
COPY src/EllieBot.Generators/*.csproj src/EllieBot.Generators/
COPY src/EllieBot.Voice/*.csproj src/EllieBot.Voice/
COPY src/EllieBot.GrpcApiBase/*.csproj src/EllieBot.GrpcApiBase/
# Restore the dependencies for the EllieBot project
RUN dotnet restore src/EllieBot/ -r linux-musl-x64
2024-06-18 23:48:54 +12:00
# Copy the rest of the source code
2024-06-18 23:48:54 +12:00
COPY . .
# Set the working directory to the EllieBot project
2024-06-18 23:48:54 +12:00
WORKDIR /source/src/EllieBot
# Build and publish the EllieBot project, then clean up unnecessary files
RUN dotnet publish -c Release -o /app --self-contained -r linux-musl-x64 --no-restore; \
2024-06-18 23:48:54 +12:00
mv /app/data /app/data_init; \
chmod +x /app/EllieBot
2024-06-18 23:48:54 +12:00
# Use the .NET 8.0 runtime as the base image for the final stage
FROM alpine:3.20
2024-06-18 23:48:54 +12:00
WORKDIR /app
# Music dependencies
# python3 required for yt-dlp, ffmpeg for conversion
2025-02-11 14:05:44 +13:00
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
2025-02-11 14:05:44 +13:00
# Required dependencies
# libc6-compat is required for .NET 8.0
# libstdc++ and libgcc are required for (.NET 8.0 ? or drawing?)
# icu-libs is required for C# globalization
2024-06-18 23:48:54 +12:00
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
2024-06-18 23:48:54 +12:00
COPY --from=build /app ./
COPY docker-entrypoint.sh /usr/local/sbin/
2024-06-18 23:48:54 +12:00
# 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
VOLUME [ "/app/data" ]
# Set the entrypoint and default command
2024-06-18 23:48:54 +12:00
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
2025-02-11 14:05:44 +13:00
CMD ./EllieBot