-
Notifications
You must be signed in to change notification settings - Fork 5
/
Containerfile
68 lines (61 loc) · 2.48 KB
/
Containerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# **IMPORTANT NOTE:**
# NOTE: This DOES NOT WORK FOR GPU until vulkan supports NON COMPUTE WORKLOADS.
# this is just a "scratchpad" for testing vkcube, but unfortunately I did not realize it was NOT a compute-based workload
# and more support is needed for display / GPU workloads. For now (see startup.sh) we are using the CPU for rendering. by supplying the
# VK_ICD_FILENAMES env var to the vulkan loader.
#
# **Description:**
#
# This is a "hello world" GPU container that showcases
# how we can use the Mac Silicon GPU within a container via showing the standard vkcube demo.
#
# **Technical Description:**
# You must use Podman Desktop with Podman 5.2.0 or above and run a
# podman machine with libkrun support.
#
# For a more technical TLDR it is:
# * Creates a virtualized Vulkan GPU interface
# * Virtualized GPU is passed to a vulkan-to-metal layer on the host MacOS
# * Uses https://github.com/containers/libkrun for all of this to work.
#
# Source code:
# In order for this to work, a patched version of mesa / vulkan is used. The source for this is located here: https://download.copr.fedorainfracloud.org/results/slp/mesa-krunkit/fedora-39-aarch64/07045714-mesa/mesa-23.3.5-102.src.rpm
#
# The following patch is applied from within the source code to get the patched mesa / vulkan to work correctly: `0001-virtio-vulkan-force-16k-alignment-for-allocations-HA.patch`
#
# **Running:**
#
# ```sh
# podman run -d \
# -p 6080:6080 \
# --device /dev/dri
# vulkan-mac-silicon-gpu-vkcube
# ```
#
# Then visit http://localhost:6080 in your browser.
FROM fedora:40
USER 0
#! Install necessary packages including X11, VNC server, noVNC, and Vulkan tools
RUN dnf -y install \
dnf-plugins-core \
xorg-x11-server-Xvfb \
tigervnc-server \
novnc \
procps \
git \
hostname && \
dnf -y copr enable slp/mesa-krunkit && \
dnf -y install mesa-vulkan-drivers vulkan-loader-devel vulkan-headers vulkan-tools vulkan-loader && \
dnf clean all
#! Clone and set up noVNC
RUN git clone https://github.com/novnc/noVNC.git /opt/noVNC && \
git clone https://github.com/novnc/websockify /opt/noVNC/utils/websockify && \
ln -s /opt/noVNC/utils/novnc_proxy /usr/local/bin/novnc_proxy && \
ln -s /opt/noVNC/vnc.html /opt/noVNC/index.html
#! Expose necessary ports
EXPOSE 6080 5900 80
#! Copy and set permissions for the startup script
COPY startup.sh /usr/local/bin/startup.sh
RUN chmod +x /usr/local/bin/startup.sh
#! Set the default command to start everything
CMD ["/usr/local/bin/startup.sh"]