-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
148 lines (139 loc) · 3.81 KB
/
Dockerfile
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Base Docker Image
ARG BASE_IMAGE=alpine:3.13
FROM ${BASE_IMAGE} as builder
# Install all needed build deps for Mesa3D
ARG LLVM_VERSION=10
RUN set -xe; \
apk add --no-cache \
autoconf \
automake \
bison \
build-base \
cmake \
elfutils-dev \
expat-dev \
flex \
gettext \
git \
glproto \
libdrm-dev \
libtool \
libva-dev \
libx11-dev \
libxcb-dev \
libxdamage-dev \
libxext-dev \
libxfixes-dev \
libxrandr-dev \
libxshmfence-dev \
libxt-dev \
libxvmc-dev \
libxxf86vm-dev \
llvm${LLVM_VERSION} \
llvm${LLVM_VERSION}-dev \
makedepend \
meson \
py-mako \
py3-libxml2 \
py3-mako \
python3 \
python3-dev \
talloc-dev \
wayland-dev \
wayland-protocols \
xorg-server-dev \
xorgproto \
zlib-dev \
zstd-dev;
# Clone Mesa source repo. (this step caches)
# Due to ongoing packaging issues we build from git vs tar packages
# Refer to https://bugs.freedesktop.org/show_bug.cgi?id=107865
ARG MESA_VERSION=21.1.1
RUN set -xe; \
mkdir -p /var/tmp/build; \
cd /var/tmp/build/; \
git clone --depth=1 --branch=mesa-${MESA_VERSION} https://gitlab.freedesktop.org/mesa/mesa.git;
# Build Mesa from source.
ARG BUILD_TYPE=release
ARG BUILD_OPTIMIZATION=3
RUN set -xe; \
cd /var/tmp/build/mesa; \
libtoolize; \
if [ "$(uname -m)" == "aarch64" ] || [ "$(uname -m)" == "armv7l" ]; \
then \
galium_drivers=swrast; \
else \
galium_drivers=swrast,swr; \
fi ;\
meson \
--buildtype=${BUILD_TYPE} \
--prefix=/usr/local \
--sysconfdir=/etc \
-D b_ndebug=true \
-D egl=true \
-D gallium-nine=false \
-D gallium-xvmc=false \
-D gbm=true \
-D gles1=false \
-D gles2=true \
-D opengl=true \
-D dri-drivers-path=/usr/local/lib/xorg/modules/dri \
-D dri-drivers= \
-D dri3=true \
-D egl=false \
-D gallium-drivers="$galium_drivers" \
-D gbm=false \
-D glx=dri \
-D llvm=true \
-D lmsensors=false \
-D optimization=${BUILD_OPTIMIZATION} \
-D osmesa=true \
-D platforms=x11,wayland \
-D shared-glapi=true \
-D shared-llvm=true \
-D vulkan-drivers= \
build/; \
ninja -C build/ -j $(getconf _NPROCESSORS_ONLN); \
ninja -C build/ install;
# The specs are built as a static program and copied to an environment that can run OpenGL apps.
FROM crystallang/crystal:1.0.0-alpine as app
RUN apk add --update --no-cache glfw-dev
COPY . ./
# RUN crystal build --static specs.cr
RUN crystal build specs.cr
# Create fresh image from alpine
FROM alpine:3.13
# Install runtime dependencies for Mesa and link xorg dri modules
ARG LLVM_VERSION=10
RUN set -xe; \
apk --update add --no-cache \
pcre \
gc \
glfw \
binutils \
expat \
llvm${LLVM_VERSION}-libs \
setxkbmap \
xdpyinfo \
xrandr \
xvfb \
xvfb-run \
zstd-libs; \
ln -sf /usr/local/lib/xorg/modules/dri/* /usr/lib/xorg/modules/dri/
# Setup our environment variables.
ENV \
GALLIUM_DRIVER="llvmpipe" \
LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" \
LIBGL_ALWAYS_SOFTWARE="1" \
LP_DEBUG="" \
LP_NO_RAST="false" \
LP_NUM_THREADS="" \
LP_PERF="" \
XVFB_WHD="1920x1080x24"
# Copy the Mesa build & entrypoint script from previous stage
COPY --from=builder /usr/local /usr/local
COPY entrypoint.sh /usr/local/bin/
COPY --from=app specs /usr/local/bin/
# Set the entrypoint script
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["/usr/local/bin/specs"]