Enhance Dockerfile: add winetricks installation and improve Wine initialization process

This commit is contained in:
2025-07-07 00:10:45 +02:00
parent 4e18d0fac1
commit 5e696ad8c0

View File

@@ -25,6 +25,7 @@ RUN dpkg --add-architecture i386 \
&& wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources \
&& apt-get update \
&& apt-get install -y --install-recommends winehq-stable \
&& apt-get install -y winetricks \
&& rm -rf /var/lib/apt/lists/*
# Create a wine user to avoid running as root
@@ -36,20 +37,29 @@ WORKDIR /home/wineuser
ENV WINEARCH=win64
ENV WINEPREFIX=/home/wineuser/.wine
ENV DISPLAY=:99
ENV WINEDLLOVERRIDES="mscoree,mshtml="
ENV WINEDEBUG=-all
# Initialize Wine prefix with virtual display
RUN Xvfb :99 -screen 0 1024x768x16 & \
sleep 2 && \
winecfg -v && \
pkill Xvfb
# Create X11 directory and initialize Wine prefix
RUN mkdir -p /tmp/.X11-unix \
&& chmod 1777 /tmp/.X11-unix \
&& Xvfb :99 -screen 0 1024x768x16 & \
XVFB_PID=$! \
&& sleep 3 \
&& wineboot --init \
&& sleep 5 \
&& wineserver --wait \
&& kill $XVFB_PID || true
# 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 \
&& Xvfb :99 -screen 0 1024x768x16 & \
&& sleep 2 \
XVFB_PID=$! \
&& sleep 3 \
&& wine dotnet-sdk-9.0.301-win-x64.exe /S /v/qn \
&& pkill Xvfb \
&& wineserver --wait \
&& kill $XVFB_PID || true \
&& rm dotnet-sdk-9.0.301-win-x64.exe
# Set environment variables for .NET
@@ -59,10 +69,11 @@ ENV PATH="$DOTNET_ROOT:$PATH"
# Create a script to run .NET commands with virtual display
RUN echo '#!/bin/bash' > /home/wineuser/run-dotnet.sh \
&& echo 'Xvfb :99 -screen 0 1024x768x16 & XVFB_PID=$!' >> /home/wineuser/run-dotnet.sh \
&& echo 'sleep 2' >> /home/wineuser/run-dotnet.sh \
&& echo 'sleep 3' >> /home/wineuser/run-dotnet.sh \
&& echo 'export DISPLAY=:99' >> /home/wineuser/run-dotnet.sh \
&& echo 'wine dotnet "$@"' >> /home/wineuser/run-dotnet.sh \
&& echo 'kill $XVFB_PID' >> /home/wineuser/run-dotnet.sh \
&& echo 'wineserver --wait' >> /home/wineuser/run-dotnet.sh \
&& echo 'kill $XVFB_PID || true' >> /home/wineuser/run-dotnet.sh \
&& chmod +x /home/wineuser/run-dotnet.sh
# Verify installation