Skip to content

Instantly share code, notes, and snippets.

@rgov
Created September 13, 2022 21:06

Revisions

  1. rgov created this gist Sep 13, 2022.
    46 changes: 46 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    # The apt repositories for ARM and Intel/AMD are hosted on different servers
    # (ports.ubuntu.com vs archive.ubuntu.com), which requires some finagling to get
    # apt's sources correct so we can install i386 packages regardless of our native
    # platform.
    #
    # There are no official i386 containers for Ubuntu 20.04 "Focal" and newer, so
    # we assume that we can use the amd64
    ARG UBUNTU_VERSION=22.04
    FROM --platform=linux/amd64 ubuntu:${UBUNTU_VERSION} AS amd64-base


    ARG UBUNTU_VERSION
    FROM ubuntu:${UBUNTU_VERSION}

    # Copy the apt source list from the arm64 image, then patch it to use i386
    COPY --from=amd64-base /etc/apt/sources.list /etc/apt/sources.list.d/i386.list

    RUN sed -i -E -e 's/^deb /deb [arch=i386] /' /etc/apt/sources.list.d/i386.list \
    && sed -i -E -e 's/^deb /deb [arch='"$(dpkg --print-architecture)"'] /' \
    /etc/apt/sources.list

    # Install required packages
    RUN export DEBIAN_FRONTEND=noninteractive \
    && dpkg --add-architecture i386 \
    && apt update \
    && apt install --no-install-recommends -y \
    openbox \
    winbind \
    wine32:i386 \
    wine-stable \
    x11vnc \
    xvfb \
    && rm -rf /var/lib/apt/lists/*

    # Configure the virtual display port
    ENV DISPLAY :0

    # Configure WINE settings
    ENV WINEDEBUG -all
    ENV WINEPREFIX /wine/

    # Expose VNC port
    EXPOSE 5900

    COPY ./start.sh
    CMD [ "./start.sh" ]
    5 changes: 5 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    It is challenging to build a multi-platform Docker container capable of running 32-bit Windows (x86) binaries under WINE.

    This Dockerfile shows one way to do so. The trick is to set up your apt source lists correctly, which is tricky to do if you are building on an ARM-based platform like a Rasberry Pi or Apple Silicon Mac.

    This image is based on Ubuntu 22.04, though it should work with other Ubuntu releases.
    12 changes: 12 additions & 0 deletions start.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/bin/bash -eu

    VNC_PASSWORD=password

    # Start VNC
    # https://benjaminknofe.com/blog/2014/06/23/osx-compatible-x11vnc-start-up-command
    Xvfb :0 -screen 0 1024x768x24 & \
    openbox & \
    x11vnc -passwd "$VNC_PASSWORD" -q -forever -loop -shared &

    # Assuming you have copied ./foobar.exe to the container...
    wine ./foobar.exe