From c7a5881445a1ec61e633057f19d3b4ab1c9eeb76 Mon Sep 17 00:00:00 2001 From: b3ni15 Date: Mon, 7 Jul 2025 00:31:20 +0200 Subject: [PATCH] Enhance Dockerfile: add logging for .NET SDK download, improve script for running .NET commands, and ensure Xvfb starts automatically in the shell --- Dockerfile | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d71ed98..29eb458 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,12 +70,15 @@ RUN Xvfb :99 -screen 0 1024x768x16 & \ # Download and install .NET SDK with virtual display RUN cd /tmp \ && wget https://builds.dotnet.microsoft.com/dotnet/Sdk/9.0.301/dotnet-sdk-9.0.301-win-x64.exe \ + && echo "Download completed, file size: $(ls -lh dotnet-sdk-9.0.301-win-x64.exe)" \ + && sleep 2 \ && Xvfb :99 -screen 0 1024x768x16 & \ XVFB_PID=$! \ && sleep 3 \ && wine dotnet-sdk-9.0.301-win-x64.exe /quiet \ && wineserver --wait \ - && kill $XVFB_PID || true + && kill $XVFB_PID || true \ + && rm dotnet-sdk-9.0.301-win-x64.exe || true # Set environment variables for .NET ENV DOTNET_ROOT="$WINEPREFIX/drive_c/Program Files/dotnet" @@ -85,10 +88,29 @@ ENV PATH="$DOTNET_ROOT:$PATH" RUN Xvfb :99 -screen 0 1024x768x16 & \ XVFB_PID=$! \ && sleep 3 \ - && dotnet --version \ + && wine dotnet --version \ && wineserver --wait \ && kill $XVFB_PID || true +# Create a script to run .NET commands with virtual display +RUN echo '#!/bin/bash' > /home/wineuser/run-dotnet.sh \ + && echo 'export DISPLAY=:99' >> /home/wineuser/run-dotnet.sh \ + && echo 'wine dotnet "$@"' >> /home/wineuser/run-dotnet.sh \ + && chmod +x /home/wineuser/run-dotnet.sh + +# Create dotnet alias and add to PATH +RUN echo 'alias dotnet="/home/wineuser/run-dotnet.sh"' >> /home/wineuser/.bashrc \ + && echo 'export PATH="/home/wineuser:$PATH"' >> /home/wineuser/.bashrc \ + && echo 'export DISPLAY=:99' >> /home/wineuser/.bashrc \ + && ln -s /home/wineuser/run-dotnet.sh /home/wineuser/dotnet + +# Start Xvfb automatically when shell starts +RUN echo 'if ! pgrep Xvfb > /dev/null; then' >> /home/wineuser/.bashrc \ + && echo ' echo "Starting Xvfb display server..."' >> /home/wineuser/.bashrc \ + && echo ' Xvfb :99 -screen 0 1024x768x16 &' >> /home/wineuser/.bashrc \ + && echo ' sleep 2' >> /home/wineuser/.bashrc \ + && echo 'fi' >> /home/wineuser/.bashrc + # Set working directory for projects WORKDIR /home/wineuser/projects