Refactor Dockerfile and entrypoint: switch to a new base image, streamline .NET SDK installation, and enhance entrypoint script for better environment setup
This commit is contained in:
134
Dockerfile
134
Dockerfile
@@ -1,101 +1,51 @@
|
||||
# Use Ubuntu as base image for better Wine support
|
||||
FROM ubuntu:22.04
|
||||
FROM --platform=$TARGETOS/$TARGETARCH ghcr.io/parkervcp/yolks:debian
|
||||
|
||||
# Avoid interactive prompts during installation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
LABEL author="Torsten Widmann" maintainer="info@goover.de"
|
||||
|
||||
# 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/*
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# 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/*
|
||||
RUN apt update -y \
|
||||
&& apt upgrade -y \
|
||||
&& apt install -y apt-transport-https wget curl iproute2 libgdiplus tini \
|
||||
&& 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')" \
|
||||
&& chmod +x dotnet-install.sh \
|
||||
&& ./dotnet-install.sh -i /usr/share -v $D_V \
|
||||
&& ln -s /usr/share/dotnet /usr/bin/dotnet
|
||||
|
||||
# Create a wine user to avoid running as root
|
||||
RUN useradd -m -s /bin/bash -u 1000 wineuser
|
||||
USER wineuser
|
||||
WORKDIR /home/wineuser
|
||||
# Install Wine and dependencies
|
||||
RUN dpkg --add-architecture i386 \
|
||||
&& apt update -y \
|
||||
&& apt install -y software-properties-common gnupg2 \
|
||||
&& wget -qO - https://dl.winehq.org/wine-builds/winehq.key | apt-key add - \
|
||||
&& echo "deb https://dl.winehq.org/wine-builds/debian/ bullseye main" >> /etc/apt/sources.list.d/winehq.list \
|
||||
&& apt update -y \
|
||||
&& apt install -y winehq-stable \
|
||||
&& apt install -y winetricks \
|
||||
&& apt install -y xvfb \
|
||||
&& apt clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
USER container
|
||||
ENV USER=container HOME=/home/container
|
||||
|
||||
# Set Wine to 64-bit mode
|
||||
ENV WINEARCH=win64
|
||||
ENV WINEPREFIX=/home/wineuser/.wine
|
||||
ENV DISPLAY=:99
|
||||
ENV WINEDLLOVERRIDES="mscoree,mshtml="
|
||||
ENV WINEDEBUG=-all
|
||||
# Wine environment variables
|
||||
ENV WINEARCH=win64
|
||||
ENV WINEPREFIX=/home/container/.wine
|
||||
ENV DISPLAY=:99.0
|
||||
|
||||
# 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
|
||||
# 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
|
||||
|
||||
# Set additional environment variables
|
||||
ENV XDG_RUNTIME_DIR=/run/user/1000
|
||||
WORKDIR /home/container
|
||||
|
||||
# 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
|
||||
STOPSIGNAL SIGINT
|
||||
|
||||
# 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 .NET SDK
|
||||
RUN cd /tmp \
|
||||
&& wget --progress=bar:force https://builds.dotnet.microsoft.com/dotnet/Sdk/9.0.301/dotnet-sdk-9.0.301-win-x64.exe \
|
||||
&& echo "Download completed, file size: $(ls -lh dotnet-sdk-9.0.301-win-x64.exe)"
|
||||
|
||||
# Install .NET SDK with virtual display
|
||||
RUN cd /tmp \
|
||||
&& Xvfb :99 -screen 0 1024x768x16 & \
|
||||
XVFB_PID=$! \
|
||||
&& sleep 3 \
|
||||
&& wine dotnet-sdk-9.0.301-win-x64.exe /S || wine dotnet-sdk-9.0.301-win-x64.exe /quiet || wine dotnet-sdk-9.0.301-win-x64.exe \
|
||||
&& 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 \
|
||||
&& wine dotnet --version \
|
||||
&& wineserver --wait \
|
||||
&& kill $XVFB_PID || true
|
||||
|
||||
# Set working directory for projects
|
||||
WORKDIR /home/wineuser/projects
|
||||
|
||||
# Default command
|
||||
CMD ["/bin/bash"]
|
||||
COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
ENTRYPOINT ["/usr/bin/tini", "-g", "--"]
|
||||
CMD ["/entrypoint.sh"]
|
Reference in New Issue
Block a user