Enhance Dockerfile and entrypoint: update Wine installation process for improved security and add integration test script for Wine and .NET

This commit is contained in:
2025-07-07 00:53:45 +02:00
parent 0e663abb0a
commit 12091eb3bc
3 changed files with 40 additions and 13 deletions

View File

@@ -16,13 +16,14 @@ RUN apt update -y \
# Install Wine and dependencies # Install Wine and dependencies
RUN dpkg --add-architecture i386 \ RUN dpkg --add-architecture i386 \
&& apt update -y \ && apt update -y \
&& apt install -y software-properties-common gnupg2 \ && apt install -y software-properties-common gnupg2 ca-certificates \
&& wget -qO - https://dl.winehq.org/wine-builds/winehq.key | apt-key add - \ && wget -qO - https://dl.winehq.org/wine-builds/winehq.key | gpg --dearmor -o /usr/share/keyrings/winehq-archive-keyring.gpg \
&& echo "deb https://dl.winehq.org/wine-builds/debian/ bullseye main" >> /etc/apt/sources.list.d/winehq.list \ && echo "deb [signed-by=/usr/share/keyrings/winehq-archive-keyring.gpg] https://dl.winehq.org/wine-builds/debian/ bullseye main" >> /etc/apt/sources.list.d/winehq.list \
&& apt update -y \ && apt update -y \
&& apt install -y winehq-stable \ && apt install -y winehq-stable \
&& apt install -y winetricks \ && apt install -y xvfb cabextract \
&& apt install -y xvfb \ && wget -q https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks -O /usr/local/bin/winetricks \
&& chmod +x /usr/local/bin/winetricks \
&& apt clean \ && apt clean \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
USER container USER container
@@ -33,19 +34,13 @@ ENV WINEARCH=win64
ENV WINEPREFIX=/home/container/.wine ENV WINEPREFIX=/home/container/.wine
ENV DISPLAY=:99.0 ENV DISPLAY=:99.0
# Initialize Wine prefix as container user
RUN Xvfb :99 -screen 0 1024x768x16 & \
export DISPLAY=:99.0 && \
wine --version && \
wineboot --init && \
winetricks -q corefonts && \
pkill Xvfb
WORKDIR /home/container WORKDIR /home/container
STOPSIGNAL SIGINT STOPSIGNAL SIGINT
COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh
COPY --chown=container:container ./../test-wine-dotnet.sh /test-wine-dotnet.sh
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh
RUN chmod +x /test-wine-dotnet.sh
ENTRYPOINT ["/usr/bin/tini", "-g", "--"] ENTRYPOINT ["/usr/bin/tini", "-g", "--"]
CMD ["/entrypoint.sh"] CMD ["/entrypoint.sh"]

View File

@@ -12,6 +12,14 @@ export DOTNET_ROOT=/usr/share/
Xvfb :99 -screen 0 1024x768x16 & Xvfb :99 -screen 0 1024x768x16 &
export DISPLAY=:99.0 export DISPLAY=:99.0
# Initialize Wine prefix if it doesn't exist
if [ ! -d "$WINEPREFIX" ]; then
echo "Initializing Wine prefix..."
wineboot --init
winetricks -q corefonts
echo "Wine initialization complete."
fi
# print the dotnet version on startup # print the dotnet version on startup
printf "\033[1m\033[33mcontainer@pelican~ \033[0mdotnet --version\n" printf "\033[1m\033[33mcontainer@pelican~ \033[0mdotnet --version\n"
dotnet --version dotnet --version

24
test-wine-dotnet.sh Normal file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
echo "Testing Wine + .NET integration..."
# Test 1: Check if .NET works natively
echo "1. Testing native .NET:"
dotnet --version
# Test 2: Check if Wine works
echo "2. Testing Wine:"
wine --version
# Test 3: Test Wine with .NET (this will use .NET through Wine)
echo "3. Testing .NET through Wine:"
wine dotnet --version
# Test 4: Create a simple .NET console app and run it through Wine
echo "4. Creating and running a simple .NET app through Wine:"
dotnet new console -n TestApp -o /tmp/testapp
cd /tmp/testapp
dotnet build
wine dotnet /tmp/testapp/bin/Debug/net9.0/TestApp.dll
echo "Wine + .NET integration test completed!"