Skip to content

Instantly share code, notes, and snippets.

@jensmeder
Last active June 20, 2023 13:39
Show Gist options
  • Save jensmeder/96e258c48d7ef0b3e828a453c2fc667f to your computer and use it in GitHub Desktop.
Save jensmeder/96e258c48d7ef0b3e828a453c2fc667f to your computer and use it in GitHub Desktop.
Hello World Example For Wine Mono Running in Ubuntu Docker Container
##########################################################
### ###
### The build stage that compiles the exe file ###
### ###
##########################################################
FROM ubuntu:18.04 as build_stage
# Install wget
RUN apt-get update
RUN apt-get install -y wget
# Add 32-bit architecture
RUN dpkg --add-architecture i386
RUN apt-get update
# Install Wine
RUN apt-get install -y software-properties-common gnupg2
RUN wget -nc https://dl.winehq.org/wine-builds/winehq.key
RUN apt-key add winehq.key
RUN apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main'
RUN apt-get install -y --install-recommends winehq-stable winbind
# Turn off Fixme warnings
ENV WINEDEBUG=fixme-all
# Setup a Wine prefix
ENV WINEPREFIX=/root/.net
ENV WINEARCH=win64
RUN winecfg
# Install Winetricks
RUN apt-get install -y cabextract
RUN wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
RUN chmod +x winetricks
RUN cp winetricks /usr/local/bin
# Install .NET Framework 4.5.2
RUN wineboot -u && winetricks -q dotnet452
# Compile HelloWorld.cs
COPY HelloWorld.cs /root/.net/drive_c/HelloWorld.cs
WORKDIR /root/.net/drive_c/
RUN wine /root/.net/drive_c/windows/Microsoft.NET/Framework64/v4.0.30319/csc.exe HelloWorld.cs
#########################################################
### ###
### The final image that runs the exe ###
### ###
#########################################################
FROM ubuntu:18.04
# Install wget
RUN apt-get update
RUN apt-get install -y wget
# Add 32-bit architecture
RUN dpkg --add-architecture i386
RUN apt-get update
# Install Wine
RUN apt-get install -y software-properties-common gnupg2
RUN wget -nc https://dl.winehq.org/wine-builds/winehq.key
RUN apt-key add winehq.key
RUN apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main'
RUN apt-get install -y --install-recommends winehq-stable winbind
ENV WINEDEBUG=fixme-all
# Setup a Wine prefix
ENV WINEPREFIX=/root/.demo
ENV WINEARCH=win64
RUN winecfg
# Install Mono
RUN wget -P /mono http://dl.winehq.org/wine/wine-mono/4.9.4/wine-mono-4.9.4.msi
RUN wineboot -u && msiexec /i /mono/wine-mono-4.9.4.msi
RUN rm -rf /mono/wine-mono-4.9.4.msi
# Copy the HelloWorld.exe from the build stage
COPY --from=build_stage /root/.net/drive_c/HelloWorld.exe /HelloWorld.exe
# Run the HelloWorld.exe
ENTRYPOINT [ "wine", "/HelloWorld.exe"]
using System;
namespace HelloWorld {
class Program {
static void Main(string[] args) {
Console.WriteLine("\n\n Hello World!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment