mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Merge branch 'v5' into 'v5'
Updating Dockerfile See merge request Kwoth/nadekobot!322
This commit is contained in:
22
Dockerfile
22
Dockerfile
@@ -1,16 +1,25 @@
|
|||||||
|
# Use the .NET 8.0 SDK as the base image for the build stage
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
WORKDIR /source
|
WORKDIR /source
|
||||||
|
|
||||||
|
# Copy the .csproj files for each project
|
||||||
COPY src/Nadeko.Medusa/*.csproj src/Nadeko.Medusa/
|
COPY src/Nadeko.Medusa/*.csproj src/Nadeko.Medusa/
|
||||||
COPY src/NadekoBot/*.csproj src/NadekoBot/
|
COPY src/NadekoBot/*.csproj src/NadekoBot/
|
||||||
COPY src/NadekoBot.Coordinator/*.csproj src/NadekoBot.Coordinator/
|
COPY src/NadekoBot.Coordinator/*.csproj src/NadekoBot.Coordinator/
|
||||||
COPY src/NadekoBot.Generators/*.csproj src/NadekoBot.Generators/
|
COPY src/NadekoBot.Generators/*.csproj src/NadekoBot.Generators/
|
||||||
COPY src/NadekoBot.Voice/*.csproj src/NadekoBot.Voice/
|
COPY src/NadekoBot.Voice/*.csproj src/NadekoBot.Voice/
|
||||||
COPY NuGet.Config ./
|
COPY NuGet.Config ./
|
||||||
|
|
||||||
|
# Restore the dependencies for the NadekoBot project
|
||||||
RUN dotnet restore src/NadekoBot/
|
RUN dotnet restore src/NadekoBot/
|
||||||
|
|
||||||
|
# Copy the rest of the source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Set the working directory to the NadekoBot project
|
||||||
WORKDIR /source/src/NadekoBot
|
WORKDIR /source/src/NadekoBot
|
||||||
|
|
||||||
|
# Build and publish the NadekoBot project, then clean up unnecessary files
|
||||||
RUN set -xe; \
|
RUN set -xe; \
|
||||||
dotnet --version; \
|
dotnet --version; \
|
||||||
dotnet publish -c Release -o /app --no-restore; \
|
dotnet publish -c Release -o /app --no-restore; \
|
||||||
@@ -19,28 +28,33 @@ RUN set -xe; \
|
|||||||
find /app -type f -exec chmod -x {} \; ;\
|
find /app -type f -exec chmod -x {} \; ;\
|
||||||
chmod +x /app/NadekoBot
|
chmod +x /app/NadekoBot
|
||||||
|
|
||||||
# final stage/image
|
# Use the .NET 8.0 runtime as the base image for the final stage
|
||||||
FROM mcr.microsoft.com/dotnet/runtime:8.0
|
FROM mcr.microsoft.com/dotnet/runtime:8.0
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Create a new user, install dependencies, and set up sudoers file
|
||||||
RUN set -xe; \
|
RUN set -xe; \
|
||||||
useradd -m nadeko; \
|
useradd -m nadeko; \
|
||||||
apt-get update; \
|
apt-get update; \
|
||||||
apt-get install -y --no-install-recommends libopus0 libsodium23 libsqlite3-0 curl ffmpeg python3 sudo; \
|
apt-get install -y --no-install-recommends libsqlite3-0 curl ffmpeg sudo python3; \
|
||||||
update-alternatives --install /usr/local/bin/python python /usr/bin/python3.9 1; \
|
|
||||||
echo 'Defaults>nadeko env_keep+="ASPNETCORE_* DOTNET_* NadekoBot_* shard_id total_shards TZ"' > /etc/sudoers.d/nadeko; \
|
echo 'Defaults>nadeko env_keep+="ASPNETCORE_* DOTNET_* NadekoBot_* shard_id total_shards TZ"' > /etc/sudoers.d/nadeko; \
|
||||||
curl -Lo /usr/local/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp; \
|
curl -Lo /usr/local/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp; \
|
||||||
chmod a+rx /usr/local/bin/yt-dlp; \
|
chmod a+rx /usr/local/bin/yt-dlp; \
|
||||||
apt-get autoremove -y; \
|
apt-get autoremove -y; \
|
||||||
apt-get autoclean -y
|
apt-get autoclean -y
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Set environment variables
|
||||||
ENV shard_id=0
|
ENV shard_id=0
|
||||||
ENV total_shards=1
|
ENV total_shards=1
|
||||||
ENV NadekoBot__creds=/app/data/creds.yml
|
ENV NadekoBot__creds=/app/data/creds.yml
|
||||||
|
|
||||||
|
# Define the data directory as a volume
|
||||||
VOLUME [ "/app/data" ]
|
VOLUME [ "/app/data" ]
|
||||||
|
|
||||||
|
# Set the entrypoint and default command
|
||||||
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
|
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
|
||||||
CMD dotnet NadekoBot.dll "$shard_id" "$total_shards"
|
CMD dotnet NadekoBot.dll "$shard_id" "$total_shards"
|
Reference in New Issue
Block a user