Started cleanup of docker related files

This commit is contained in:
Toastie 2025-02-11 12:27:12 +13:00
parent acdb707a31
commit d9c27021aa
Signed by: toastie_t0ast
GPG key ID: 0861BE54AD481DC7
2 changed files with 10 additions and 26 deletions

View file

@ -19,29 +19,21 @@ 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 set -xe; \ RUN dotnet restore
dotnet --version; \ RUN dotnet publish -c Release -o /app --self-contained -r linux-x64 --no-restore; \
dotnet restore; \
dotnet publish -c Release -o /app --no-restore; \
mv /app/data /app/data_init; \ mv /app/data /app/data_init; \
rm -Rf libopus* libsodium* opus.* runtimes/win* runtimes/osx* runtimes/linux-arm* runtimes/linux-mips*; \ chmod +x /app/EllieBot
find /app -type f -exec chmod -x {} \; ;\
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 mcr.microsoft.com/dotnet/runtime:8.0 FROM debian:12.9-slim
WORKDIR /app WORKDIR /app
# Create a new user, install dependencies, and set up sudoers file # Create a new user, install dependencies, and set up sudoers file
RUN set -xe; \ RUN apt update; \
useradd -m ellie; \ apt install -y curl ffmpeg python3; \
apt-get update; \
apt-get install -y --no-install-recommends libopus0 libsodium23 libsqlite3-0 curl ffmpeg python3 sudo; \
echo 'Defaults>ellie env_keep+="ASPNETCORE_* DOTNET_* EllieBot_* shard_id total_shards TZ"' > /etc/sudoers.d/ellie; \
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 autoremove -y;
apt-get autoclean -y
# 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 ./
@ -50,11 +42,11 @@ COPY docker-entrypoint.sh /usr/local/sbin
# Set environment variables # Set environment variables
ENV shard_id=0 ENV shard_id=0
ENV total_shards=1 ENV total_shards=1
ENV EllieBot__creds=/app/data/creds.yml
# Define the data directory as a volume # Define the data directory as a volume
VOLUME [" /app/data "] VOLUME [ "/app/data" ]
# Set the entrypoint and default command # Set the entrypoint and default command
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ] ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
CMD dotnet EllieBot.dll "$shard_id" "$total_shards" CMD yt-dlp -U &2>/dev/null
CMD dotnet EllieBot.dll "$shard_id" "$total_shards"

View file

@ -13,14 +13,6 @@ do
fi fi
done done
# creds.yml migration
if [ -f /app/creds.yml ]; then
echo "Default location for creds.yml is now /app/data/creds.yml."
echo "Please move your creds.yml and update your docker-compose.yml accordingly."
export Ellie_creds=/app/creds.yml
fi
# ensure ellie can write on /app/data # ensure ellie can write on /app/data
chown -R ellie:ellie "$data" chown -R ellie:ellie "$data"