Refactor Dockerfile and entrypoint script: update DotNet installation process, switch to Wine development version, and streamline Wine initialization

This commit is contained in:
2025-07-07 14:07:45 +02:00
parent 87a1ee9295
commit c8c901bd7f
2 changed files with 25 additions and 36 deletions

View File

@@ -10,7 +10,7 @@ RUN apt update -y \
&& wget https://dot.net/v1/dotnet-install.sh \ && wget https://dot.net/v1/dotnet-install.sh \
&& D_V="$(curl -sSL https://dotnet.microsoft.com/en-us/download/dotnet/9.0 | grep -i '<h3 id="sdk-9.*">SDK 9.*.*</h3>' | head -1 | awk -F\" '{print $3}' | awk '{print $2;}' | sed 's/<\/h3>//g')" \ && D_V="$(curl -sSL https://dotnet.microsoft.com/en-us/download/dotnet/9.0 | grep -i '<h3 id="sdk-9.*">SDK 9.*.*</h3>' | head -1 | awk -F\" '{print $3}' | awk '{print $2;}' | sed 's/<\/h3>//g')" \
&& chmod +x dotnet-install.sh \ && chmod +x dotnet-install.sh \
&& ./dotnet-install.sh -i /usr/share -v $D_V \ && ./dotnet-install.sh -i /usr/share -v $D_V \
&& ln -s /usr/share/dotnet /usr/bin/dotnet && ln -s /usr/share/dotnet /usr/bin/dotnet
# Install Wine and dependencies # Install Wine and dependencies
@@ -20,12 +20,13 @@ RUN dpkg --add-architecture i386 \
&& wget -qO - https://dl.winehq.org/wine-builds/winehq.key | gpg --dearmor -o /usr/share/keyrings/winehq-archive-keyring.gpg \ && wget -qO - https://dl.winehq.org/wine-builds/winehq.key | gpg --dearmor -o /usr/share/keyrings/winehq-archive-keyring.gpg \
&& 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 \ && 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 --install-recommends winehq-devel \
&& apt install -y xvfb cabextract \ && apt install -y xvfb cabextract \
&& wget -q https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks -O /usr/local/bin/winetricks \ && wget -q https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks -O /usr/local/bin/winetricks \
&& chmod +x /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
ENV USER=container HOME=/home/container ENV USER=container HOME=/home/container
@@ -33,6 +34,7 @@ ENV USER=container HOME=/home/container
ENV WINEARCH=win64 ENV WINEARCH=win64
ENV WINEPREFIX=/home/container/.wine ENV WINEPREFIX=/home/container/.wine
ENV DISPLAY=:99.0 ENV DISPLAY=:99.0
ENV WINEDLLOVERRIDES="mscoree,mshtml="
WORKDIR /home/container WORKDIR /home/container
@@ -40,5 +42,5 @@ STOPSIGNAL SIGINT
COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/usr/bin/tini", "-g", "--"] ENTRYPOINT ["/usr/bin/tini", "-g", "--"]
CMD ["/entrypoint.sh"] CMD ["/entrypoint.sh"]

View File

@@ -5,7 +5,7 @@ cd /home/container
INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}') INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}')
export INTERNAL_IP export INTERNAL_IP
# set this variable, dotnet needs it even without it it reports to `dotnet --info` it can not start any aplication without this # DotNet environment setup
export DOTNET_ROOT=/usr/share/ export DOTNET_ROOT=/usr/share/
# Fix X11 permissions # Fix X11 permissions
@@ -15,44 +15,31 @@ chmod 1777 /tmp/.X11-unix
# Start Xvfb for Wine (virtual display) # Start Xvfb for Wine (virtual display)
Xvfb :99 -screen 0 1024x768x16 -ac & Xvfb :99 -screen 0 1024x768x16 -ac &
export DISPLAY=:99.0 export DISPLAY=:99.0
sleep 3
# Wait for Xvfb to start # Wine configuration
sleep 5
# Force reinitialize Wine prefix to ensure it's properly set up
echo "Reinitializing Wine prefix to ensure proper setup..."
rm -rf "$WINEPREFIX"
# Set Wine architecture to 64-bit
export WINEARCH=win64 export WINEARCH=win64
export WINEPREFIX=/home/container/.wine
export WINEDLLOVERRIDES="mscoree,mshtml="
# Initialize Wine prefix synchronously with timeout if [ ! -d "$WINEPREFIX" ]; then
echo "Creating new Wine prefix..." echo "Initializing Wine prefix..."
timeout 30 wineboot --init || echo "Wineboot timed out, continuing..." wine wineboot --init
sleep 10
# Wait a bit more for any background processes
sleep 5 # Install essential components
winetricks -q vcrun2019 corefonts
# Kill any hanging wine processes sleep 5
pkill -f wine || true
# Skip winetricks for now as it may cause issues
echo "Skipping winetricks installation to avoid hanging..."
# Test Wine installation with a simple command
echo "Testing Wine installation..."
timeout 10 wine cmd /c "echo Wine test successful" 2>/dev/null
if [ $? -eq 0 ]; then
echo "Wine initialization complete and verified."
else
echo "Wine test failed, but Wine prefix was created. Continuing..."
fi fi
# print the dotnet version on startup # Start Wine server
wineserver -p &> /dev/null
sleep 3
# Print versions
printf "\033[1m\033[33mcontainer@pelican~ \033[0mdotnet --version\n" printf "\033[1m\033[33mcontainer@pelican~ \033[0mdotnet --version\n"
dotnet --version dotnet --version
# print the wine version on startup
printf "\033[1m\033[33mcontainer@pelican~ \033[0mwine --version\n" printf "\033[1m\033[33mcontainer@pelican~ \033[0mwine --version\n"
wine --version wine --version
@@ -61,4 +48,4 @@ MODIFIED_STARTUP=$(echo -e ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')
echo -e ":/home/container$ ${MODIFIED_STARTUP}" echo -e ":/home/container$ ${MODIFIED_STARTUP}"
# Run the Server # Run the Server
eval ${MODIFIED_STARTUP} eval ${MODIFIED_STARTUP}