elliebot/Dockerfile

52 lines
1.7 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-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-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 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
# Create a new user, install dependencies, and set up sudoers file
RUN apt update; \
2025-02-11 14:05:44 +13:00
apt install -y --no-install-recommends ffmpeg python3; \
apt autoremove -y; \
apt clean -y;
2024-06-18 23:48:54 +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-11 14:05:44 +13:00
COPY --chmod=755 docker-entrypoint.sh /usr/local/sbin/
2024-06-18 23:48:54 +12:00
# Set environment variables
2024-06-18 23:48:54 +12:00
ENV shard_id=0
ENV total_shards=1
# 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