2024-08-07 12:09:11 +12:00
|
|
|
# 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
|
|
|
|
|
2024-08-07 12:09:11 +12:00
|
|
|
# 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/
|
2025-02-11 13:59:12 +13:00
|
|
|
COPY src/EllieBot.GrpcApiBase/*.csproj src/EllieBot.GrpcApiBase/
|
2024-08-07 12:09:11 +12:00
|
|
|
|
|
|
|
# Restore the dependencies for the EllieBot project
|
2025-02-11 13:59:12 +13:00
|
|
|
RUN dotnet restore src/EllieBot/ -r linux-x64
|
2024-06-18 23:48:54 +12:00
|
|
|
|
2024-08-07 12:09:11 +12:00
|
|
|
# Copy the rest of the source code
|
2024-06-18 23:48:54 +12:00
|
|
|
COPY . .
|
2024-08-07 12:09:11 +12:00
|
|
|
|
|
|
|
# Set the working directory to the EllieBot project
|
2024-06-18 23:48:54 +12:00
|
|
|
WORKDIR /source/src/EllieBot
|
2024-08-07 12:09:11 +12:00
|
|
|
|
|
|
|
# Build and publish the EllieBot project, then clean up unnecessary files
|
2025-02-11 12:27:12 +13:00
|
|
|
RUN dotnet publish -c Release -o /app --self-contained -r linux-x64 --no-restore; \
|
2024-06-18 23:48:54 +12:00
|
|
|
mv /app/data /app/data_init; \
|
2025-02-11 12:27:12 +13:00
|
|
|
chmod +x /app/EllieBot
|
2024-06-18 23:48:54 +12:00
|
|
|
|
2024-08-07 12:09:11 +12:00
|
|
|
# Use the .NET 8.0 runtime as the base image for the final stage
|
2025-02-11 12:27:12 +13:00
|
|
|
FROM debian:12.9-slim
|
2024-06-18 23:48:54 +12:00
|
|
|
WORKDIR /app
|
|
|
|
|
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
|
|
|
|
|
2024-08-07 12:09:11 +12:00
|
|
|
# Create a new user, install dependencies, and set up sudoers file
|
2025-02-11 12:27:12 +13:00
|
|
|
RUN apt update; \
|
2025-02-13 12:19:03 +13:00
|
|
|
apt install -y --no-install-recommends \
|
|
|
|
libicu-dev ca-certificates \
|
|
|
|
ffmpeg python3; \
|
2025-02-11 13:59:12 +13:00
|
|
|
apt autoremove -y; \
|
|
|
|
apt clean -y;
|
2024-06-18 23:48:54 +12:00
|
|
|
|
2025-02-13 12:19:03 +13:00
|
|
|
RUN update-ca-certificates
|
|
|
|
|
2024-08-07 12:09:11 +12:00
|
|
|
# Copy the built application and the entrypoint script from the build stage
|
2024-06-18 23:48:54 +12:00
|
|
|
COPY --from=build /app ./
|
2025-02-13 12:19:03 +13:00
|
|
|
COPY docker-entrypoint.sh /usr/local/sbin/
|
2024-06-18 23:48:54 +12:00
|
|
|
|
2024-08-07 12:09:11 +12:00
|
|
|
# Define the data directory as a volume
|
2025-02-11 12:27:12 +13:00
|
|
|
VOLUME [ "/app/data" ]
|
2024-08-07 12:09:11 +12:00
|
|
|
|
|
|
|
# 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
|