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 --platform=$TARGETOS/$TARGETARCH ghcr.io/parkervcp/yolks:debian
|
||||||
FROM ubuntu:22.04
|
|
||||||
|
|
||||||
# Avoid interactive prompts during installation
|
LABEL author="Torsten Widmann" maintainer="info@goover.de"
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
# Update system and install necessary packages including X11 for Wine
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
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 apt update -y \
|
||||||
RUN dpkg --add-architecture i386 \
|
&& apt upgrade -y \
|
||||||
&& mkdir -pm755 /etc/apt/keyrings \
|
&& apt install -y apt-transport-https wget curl iproute2 libgdiplus tini \
|
||||||
&& wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key \
|
&& wget https://dot.net/v1/dotnet-install.sh \
|
||||||
&& wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources \
|
&& 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')" \
|
||||||
&& apt-get update \
|
&& chmod +x dotnet-install.sh \
|
||||||
&& apt-get install -y --install-recommends winehq-stable \
|
&& ./dotnet-install.sh -i /usr/share -v $D_V \
|
||||||
&& apt-get install -y winetricks \
|
&& ln -s /usr/share/dotnet /usr/bin/dotnet
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Create a wine user to avoid running as root
|
# Install Wine and dependencies
|
||||||
RUN useradd -m -s /bin/bash -u 1000 wineuser
|
RUN dpkg --add-architecture i386 \
|
||||||
USER wineuser
|
&& apt update -y \
|
||||||
WORKDIR /home/wineuser
|
&& 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
|
# Wine environment variables
|
||||||
ENV WINEARCH=win64
|
ENV WINEARCH=win64
|
||||||
ENV WINEPREFIX=/home/wineuser/.wine
|
ENV WINEPREFIX=/home/container/.wine
|
||||||
ENV DISPLAY=:99
|
ENV DISPLAY=:99.0
|
||||||
ENV WINEDLLOVERRIDES="mscoree,mshtml="
|
|
||||||
ENV WINEDEBUG=-all
|
|
||||||
|
|
||||||
# Create necessary directories and set up environment
|
# Initialize Wine prefix as container user
|
||||||
USER root
|
RUN Xvfb :99 -screen 0 1024x768x16 & \
|
||||||
RUN mkdir -p /tmp/.X11-unix /run/user/1000 \
|
export DISPLAY=:99.0 && \
|
||||||
&& chmod 1777 /tmp/.X11-unix \
|
wine --version && \
|
||||||
&& chown wineuser:wineuser /run/user/1000
|
wineboot --init && \
|
||||||
USER wineuser
|
winetricks -q corefonts && \
|
||||||
|
pkill Xvfb
|
||||||
|
|
||||||
# Set additional environment variables
|
WORKDIR /home/container
|
||||||
ENV XDG_RUNTIME_DIR=/run/user/1000
|
|
||||||
|
|
||||||
# Create X11 directory and initialize Wine prefix
|
STOPSIGNAL SIGINT
|
||||||
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
|
COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh
|
||||||
RUN Xvfb :99 -screen 0 1024x768x16 & \
|
RUN chmod +x /entrypoint.sh
|
||||||
XVFB_PID=$! \
|
ENTRYPOINT ["/usr/bin/tini", "-g", "--"]
|
||||||
&& sleep 3 \
|
CMD ["/entrypoint.sh"]
|
||||||
&& 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"]
|
|
76
README.md
76
README.md
@@ -1,76 +0,0 @@
|
|||||||
# Wine + .NET SDK Docker Image
|
|
||||||
|
|
||||||
Ez a Docker image telepíti a Wine 64-bit verzióját és a Microsoft .NET SDK 9.0.301-et Windows-on keresztül.
|
|
||||||
|
|
||||||
## Tartalom
|
|
||||||
|
|
||||||
- Ubuntu 22.04 alapú image
|
|
||||||
- Wine 64-bit (stable verzió)
|
|
||||||
- .NET SDK 9.0.301 (Windows x64)
|
|
||||||
|
|
||||||
## Build
|
|
||||||
|
|
||||||
### Bash-sel (Git Bash, WSL, Linux, macOS):
|
|
||||||
```bash
|
|
||||||
chmod +x build.sh
|
|
||||||
./build.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
### Manuálisan:
|
|
||||||
```bash
|
|
||||||
docker build -t wine-dotnet:latest .
|
|
||||||
```
|
|
||||||
|
|
||||||
## Használat
|
|
||||||
|
|
||||||
### Alapvető futtatás:
|
|
||||||
```bash
|
|
||||||
docker run -it --rm wine-dotnet:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
### Projektekkel való munka (volume mounting):
|
|
||||||
```bash
|
|
||||||
docker run -it --rm -v $(pwd)/projects:/home/wineuser/projects wine-dotnet:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
Windows PowerShell-ben:
|
|
||||||
```powershell
|
|
||||||
docker run -it --rm -v ${PWD}/projects:/home/wineuser/projects wine-dotnet:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
## .NET használata a containerben
|
|
||||||
|
|
||||||
A containerben belül használhatod a .NET SDK-t a speciális script segítségével:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# .NET verzió ellenőrzése
|
|
||||||
./run-dotnet.sh --version
|
|
||||||
|
|
||||||
# Új projekt létrehozása
|
|
||||||
./run-dotnet.sh new console -n MyApp
|
|
||||||
|
|
||||||
# Projekt build-elése
|
|
||||||
cd MyApp
|
|
||||||
../run-dotnet.sh build
|
|
||||||
|
|
||||||
# Projekt futtatása
|
|
||||||
../run-dotnet.sh run
|
|
||||||
```
|
|
||||||
|
|
||||||
Alternatívaként közvetlenül is használhatod:
|
|
||||||
```bash
|
|
||||||
# Virtual display indítása
|
|
||||||
Xvfb :99 -screen 0 1024x768x16 &
|
|
||||||
export DISPLAY=:99
|
|
||||||
|
|
||||||
# .NET parancsok
|
|
||||||
wine dotnet --version
|
|
||||||
```
|
|
||||||
|
|
||||||
## Megjegyzések
|
|
||||||
|
|
||||||
- A container egy `wineuser` felhasználóval fut (nem root)
|
|
||||||
- A Wine prefix előre konfigurálva van 64-bit módban
|
|
||||||
- A .NET SDK csendben telepítve van virtual display segítségével
|
|
||||||
- A projektek a `/home/wineuser/projects` könyvtárban tárolhatók
|
|
||||||
- A `run-dotnet.sh` script automatikusan kezeli a virtual display-t
|
|
21
build.sh
21
build.sh
@@ -1,21 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo "Building Wine + .NET SDK Docker image..."
|
|
||||||
docker build -t wine-dotnet:latest .
|
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
echo "✅ Docker image built successfully!"
|
|
||||||
echo ""
|
|
||||||
echo "To run the container interactively:"
|
|
||||||
echo "docker run -it --rm wine-dotnet:latest"
|
|
||||||
echo ""
|
|
||||||
echo "To run with volume mounting (for development):"
|
|
||||||
echo "docker run -it --rm -v \$(pwd)/projects:/home/wineuser/projects wine-dotnet:latest"
|
|
||||||
echo ""
|
|
||||||
echo "To run a .NET application with Wine:"
|
|
||||||
echo "docker run -it --rm -v \$(pwd)/projects:/home/wineuser/projects wine-dotnet:latest"
|
|
||||||
echo "Then inside the container: wine dotnet YourApp.dll"
|
|
||||||
else
|
|
||||||
echo "❌ Failed to build Docker image"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
28
entrypoint.sh
Normal file
28
entrypoint.sh
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd /home/container
|
||||||
|
|
||||||
|
# Set environment variable that holds the Internal Docker IP
|
||||||
|
INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}')
|
||||||
|
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
|
||||||
|
export DOTNET_ROOT=/usr/share/
|
||||||
|
|
||||||
|
# Start Xvfb for Wine (virtual display)
|
||||||
|
Xvfb :99 -screen 0 1024x768x16 &
|
||||||
|
export DISPLAY=:99.0
|
||||||
|
|
||||||
|
# print the dotnet version on startup
|
||||||
|
printf "\033[1m\033[33mcontainer@pelican~ \033[0mdotnet --version\n"
|
||||||
|
dotnet --version
|
||||||
|
|
||||||
|
# print the wine version on startup
|
||||||
|
printf "\033[1m\033[33mcontainer@pelican~ \033[0mwine --version\n"
|
||||||
|
wine --version
|
||||||
|
|
||||||
|
# Replace Startup Variables
|
||||||
|
MODIFIED_STARTUP=$(echo -e ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')
|
||||||
|
echo -e ":/home/container$ ${MODIFIED_STARTUP}"
|
||||||
|
|
||||||
|
# Run the Server
|
||||||
|
eval ${MODIFIED_STARTUP}
|
Reference in New Issue
Block a user