# Use Ubuntu as base image for better Wine support FROM ubuntu:22.04 # Avoid interactive prompts during installation ENV DEBIAN_FRONTEND=noninteractive # Update system and install necessary packages including X11 for Wine RUN apt-get update && apt-get install -y \ software-properties-common \ wget \ curl \ gnupg2 \ ca-certificates \ apt-transport-https \ xvfb \ x11-utils \ x11-xserver-utils \ dbus-x11 \ && rm -rf /var/lib/apt/lists/* # Add Wine repository and install Wine 64-bit RUN dpkg --add-architecture i386 \ && mkdir -pm755 /etc/apt/keyrings \ && wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key \ && 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 RUN useradd -m -s /bin/bash -u 1000 wineuser USER wineuser WORKDIR /home/wineuser # Set Wine to 64-bit mode ENV WINEARCH=win64 ENV WINEPREFIX=/home/wineuser/.wine ENV DISPLAY=:99 ENV WINEDLLOVERRIDES="mscoree,mshtml=" ENV WINEDEBUG=-all # Create necessary directories and set up environment USER root RUN mkdir -p /tmp/.X11-unix /run/user/1000 \ && chmod 1777 /tmp/.X11-unix \ && 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 \ && sleep 5 \ && 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 /quiet \ && wineserver --wait \ && 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" ENV PATH="$DOTNET_ROOT:$PATH" # Get dotnet version to verify installation RUN Xvfb :99 -screen 0 1024x768x16 & \ XVFB_PID=$! \ && sleep 3 \ && dotnet --version \ && wineserver --wait \ && kill $XVFB_PID || true # Set working directory for projects WORKDIR /home/wineuser/projects # Default command CMD ["/bin/bash"]