Refactor Dockerfile and entrypoint script: streamline .NET installation process in Wine and enhance Wine prefix initialization
This commit is contained in:
26
Dockerfile
26
Dockerfile
@@ -27,6 +27,28 @@ RUN dpkg --add-architecture i386 \
|
|||||||
&& apt clean \
|
&& apt clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Setup Wine environment for .NET installation
|
||||||
|
ENV WINEARCH=win64
|
||||||
|
ENV WINEPREFIX=/opt/wine
|
||||||
|
ENV DISPLAY=:99.0
|
||||||
|
ENV WINEDLLOVERRIDES="mscoree,mshtml="
|
||||||
|
|
||||||
|
# Initialize Wine and install .NET for Windows
|
||||||
|
RUN mkdir -p /tmp/.X11-unix \
|
||||||
|
&& chmod 1777 /tmp/.X11-unix \
|
||||||
|
&& Xvfb :99 -screen 0 1024x768x16 -ac & \
|
||||||
|
&& sleep 3 \
|
||||||
|
&& timeout 60 wine wineboot --init \
|
||||||
|
&& sleep 5 \
|
||||||
|
&& cd /tmp \
|
||||||
|
&& wget -q https://download.microsoft.com/download/6/6/1/661c9a9c-9c54-4f8b-b1c6-89d88c0f3d68/dotnet-runtime-9.0.6-win-x64.exe \
|
||||||
|
&& timeout 180 wine dotnet-runtime-9.0.6-win-x64.exe /quiet /install \
|
||||||
|
&& wget -q https://builds.dotnet.microsoft.com/dotnet/Sdk/9.0.301/dotnet-sdk-9.0.301-win-x64.exe \
|
||||||
|
&& timeout 180 wine dotnet-sdk-9.0.301-win-x64.exe /quiet /install \
|
||||||
|
&& rm -f *.exe \
|
||||||
|
&& pkill Xvfb \
|
||||||
|
&& chown -R container:container /opt/wine
|
||||||
|
|
||||||
USER container
|
USER container
|
||||||
ENV USER=container HOME=/home/container
|
ENV USER=container HOME=/home/container
|
||||||
|
|
||||||
@@ -36,6 +58,10 @@ ENV WINEPREFIX=/home/container/.wine
|
|||||||
ENV DISPLAY=:99.0
|
ENV DISPLAY=:99.0
|
||||||
ENV WINEDLLOVERRIDES="mscoree,mshtml="
|
ENV WINEDLLOVERRIDES="mscoree,mshtml="
|
||||||
|
|
||||||
|
# Copy the pre-configured Wine prefix to user directory
|
||||||
|
RUN cp -r /opt/wine /home/container/.wine \
|
||||||
|
&& chown -R container:container /home/container/.wine
|
||||||
|
|
||||||
WORKDIR /home/container
|
WORKDIR /home/container
|
||||||
|
|
||||||
STOPSIGNAL SIGINT
|
STOPSIGNAL SIGINT
|
||||||
|
@@ -22,36 +22,19 @@ export WINEARCH=win64
|
|||||||
export WINEPREFIX=/home/container/.wine
|
export WINEPREFIX=/home/container/.wine
|
||||||
export WINEDLLOVERRIDES="mscoree,mshtml="
|
export WINEDLLOVERRIDES="mscoree,mshtml="
|
||||||
|
|
||||||
# Always reinitialize Wine prefix to ensure it works
|
# Check if Wine prefix exists, if not copy from template
|
||||||
echo "Reinitializing Wine prefix..."
|
if [ ! -d "$WINEPREFIX" ]; then
|
||||||
rm -rf "$WINEPREFIX"
|
echo "Wine prefix not found, this should not happen in Docker..."
|
||||||
|
# Fallback: reinitialize if needed
|
||||||
# Initialize Wine prefix with timeout to prevent hanging
|
echo "Reinitializing Wine prefix..."
|
||||||
echo "Creating Wine prefix..."
|
timeout 60 wine wineboot --init || echo "Wine initialization timed out"
|
||||||
timeout 60 wine wineboot --init || echo "Wine initialization timed out, continuing..."
|
sleep 5
|
||||||
|
fi
|
||||||
# Wait for Wine to settle
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
# Test if Wine works
|
# Test if Wine works
|
||||||
echo "Testing Wine..."
|
echo "Testing Wine..."
|
||||||
if timeout 10 wine cmd /c "echo Wine works"; then
|
if timeout 10 wine cmd /c "echo Wine works"; then
|
||||||
echo "Wine test successful"
|
echo "Wine test successful"
|
||||||
|
|
||||||
# Install .NET Runtime for Windows in Wine
|
|
||||||
echo "Installing .NET Runtime for Windows..."
|
|
||||||
cd /tmp
|
|
||||||
wget -q https://download.microsoft.com/download/6/6/1/661c9a9c-9c54-4f8b-b1c6-89d88c0f3d68/dotnet-runtime-9.0.6-win-x64.exe
|
|
||||||
timeout 120 wine dotnet-runtime-9.0.6-win-x64.exe /quiet /install || echo "Runtime installation timed out"
|
|
||||||
rm -f dotnet-runtime-9.0.6-win-x64.exe
|
|
||||||
|
|
||||||
# Also install .NET SDK for Windows
|
|
||||||
echo "Installing .NET SDK for Windows..."
|
|
||||||
wget -q https://builds.dotnet.microsoft.com/dotnet/Sdk/9.0.301/dotnet-sdk-9.0.301-win-x64.exe
|
|
||||||
timeout 120 wine dotnet-sdk-9.0.301-win-x64.exe /quiet /install || echo "SDK installation timed out"
|
|
||||||
rm -f dotnet-sdk-9.0.301-win-x64.exe
|
|
||||||
|
|
||||||
cd /home/container
|
|
||||||
else
|
else
|
||||||
echo "Wine test failed, but continuing..."
|
echo "Wine test failed, but continuing..."
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user