Fix Dockerfile: ensure proper user creation and enhance Wine initialization with additional dependencies

This commit is contained in:
2025-07-07 00:20:12 +02:00
parent 5e696ad8c0
commit adc4393c88

View File

@@ -29,7 +29,7 @@ RUN dpkg --add-architecture i386 \
&& rm -rf /var/lib/apt/lists/*
# Create a wine user to avoid running as root
RUN useradd -m -s /bin/bash wineuser
RUN useradd -m -s /bin/bash -u 1000 wineuser
USER wineuser
WORKDIR /home/wineuser
@@ -40,10 +40,18 @@ ENV DISPLAY=:99
ENV WINEDLLOVERRIDES="mscoree,mshtml="
ENV WINEDEBUG=-all
# Create X11 directory and initialize Wine prefix
RUN mkdir -p /tmp/.X11-unix \
# Create necessary directories and set up environment
USER root
RUN mkdir -p /tmp/.X11-unix /run/user/1000 \
&& chmod 1777 /tmp/.X11-unix \
&& Xvfb :99 -screen 0 1024x768x16 & \
&& chown wineuser:wineuser /run/user/1000
USER wineuser
# Set additional environment variables
ENV XDG_RUNTIME_DIR=/run/user/1000
# Create X11 directory and initialize Wine prefix
RUN Xvfb :99 -screen 0 1024x768x16 & \
XVFB_PID=$! \
&& sleep 3 \
&& wineboot --init \
@@ -51,16 +59,24 @@ RUN mkdir -p /tmp/.X11-unix \
&& wineserver --wait \
&& kill $XVFB_PID || true
# Install Wine dependencies for .NET
RUN Xvfb :99 -screen 0 1024x768x16 & \
XVFB_PID=$! \
&& sleep 3 \
&& winetricks -q corefonts vcrun2019 \
&& 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 & \
XVFB_PID=$! \
&& sleep 3 \
&& wine dotnet-sdk-9.0.301-win-x64.exe /S /v/qn \
&& wine dotnet-sdk-9.0.301-win-x64.exe /quiet \
&& wineserver --wait \
&& kill $XVFB_PID || true \
&& rm dotnet-sdk-9.0.301-win-x64.exe
&& rm dotnet-sdk-9.0.301-win-x64.exe || true
# Set environment variables for .NET
ENV DOTNET_ROOT="$WINEPREFIX/drive_c/Program Files/dotnet"
@@ -77,7 +93,7 @@ RUN echo '#!/bin/bash' > /home/wineuser/run-dotnet.sh \
&& chmod +x /home/wineuser/run-dotnet.sh
# Verify installation
RUN /home/wineuser/run-dotnet.sh --version
RUN /home/wineuser/run-dotnet.sh --version || echo "Installation verification failed, but continuing..."
# Set working directory for projects
WORKDIR /home/wineuser/projects