Skip to content

Commit 72415ea

Browse files
committed
Initial Commit
0 parents  commit 72415ea

11 files changed

+311
-0
lines changed

.dockerignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.git
2+
.gitignore
3+
.travis.yml
4+
README.md
5+
LICENSE
6+
hooks
7+
Dockerfile

.gitignore

Whitespace-only changes.

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: bash
2+
services: docker
3+
4+
script:
5+
- docker build -t jamesbrink/opengl .
6+
- docker images

Dockerfile

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Mesa3D Software Drivers
2+
#
3+
# VERSION 18.0.1
4+
5+
FROM alpine:3.7
6+
7+
# Build arguments.
8+
ARG VCS_REF
9+
ARG BUILD_DATE
10+
ARG MESA_DEMOS="false"
11+
12+
# Labels / Metadata.
13+
LABEL maintainer="James Brink, [email protected]" \
14+
decription="Mesa3D Software Drivers" \
15+
version="18.0.1" \
16+
org.label-schema.name="Mesa3D-Software-Drivers" \
17+
org.label-schema.build-date=$BUILD_DATE \
18+
org.label-schema.vcs-ref=$VCS_REF \
19+
org.label-schema.vcs-url="https://github.com/jamesbrink/docker-gource" \
20+
org.label-schema.schema-version="1.0.0-rc1"
21+
22+
# Install all needed deps and compile the mesa llvmpipe driver from source.
23+
RUN set -xe; \
24+
apk --update add --no-cache --virtual .runtime-deps xvfb llvm5-libs xdpyinfo; \
25+
apk add --no-cache --virtual .build-deps llvm-dev build-base zlib-dev glproto xorg-server-dev python-dev; \
26+
mkdir -p /var/tmp/build; \
27+
cd /var/tmp/build; \
28+
wget "https://mesa.freedesktop.org/archive/mesa-18.0.1.tar.gz"; \
29+
tar xfv mesa-18.0.1.tar.gz; \
30+
rm mesa-18.0.1.tar.gz; \
31+
cd mesa-18.0.1; \
32+
./configure --enable-glx=gallium-xlib --with-gallium-drivers=swrast,swr --disable-dri --disable-gbm --disable-egl --enable-gallium-osmesa --prefix=/usr/local; \
33+
make; \
34+
make install; \
35+
cd .. ; \
36+
rm -rf mesa-18.0.1; \
37+
if [ "${MESA_DEMOS}" == "true" ]; then \
38+
apk add --no-cache --virtual .mesa-demos-runtime-deps glu glew \
39+
&& apk add --no-cache --virtual .mesa-demos-build-deps glew-dev freeglut-dev \
40+
&& wget "ftp://ftp.freedesktop.org/pub/mesa/demos/mesa-demos-8.4.0.tar.gz" \
41+
&& tar xfv mesa-demos-8.4.0.tar.gz \
42+
&& rm mesa-demos-8.4.0.tar.gz \
43+
&& cd mesa-demos-8.4.0 \
44+
&& ./configure --prefix=/usr/local \
45+
&& make \
46+
&& make install \
47+
&& cd .. \
48+
&& rm -rf mesa-demos-8.4.0 \
49+
&& apk del .mesa-demos-build-deps; \
50+
fi; \
51+
apk del .build-deps;
52+
53+
# Copy our entrypoint into the container.
54+
COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh
55+
56+
# Setup our environment variables.
57+
ENV XVFB_WHD="1920x1080x24"\
58+
DISPLAY=":99" \
59+
LIBGL_ALWAYS_SOFTWARE="1" \
60+
GALLIUM_DRIVER="llvmpipe" \
61+
LP_NO_RAST="false" \
62+
LP_DEBUG="" \
63+
LP_PERF="" \
64+
LP_NUM_THREADS=""
65+
66+
# Set the default command.
67+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 James Brink
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Docker - Mesa 3D OpenGL Software Rendering (Gallium) - LLVMpipe, and OpenSWR Drivers
2+
3+
[![Build Status](https://travis-ci.org/jamesbrink/docker-opengl.svg?branch=master)](https://travis-ci.org/jamesbrink/docker-opengl) [![Docker Automated build](https://img.shields.io/docker/automated/jamesbrink/opengl.svg)](https://hub.docker.com/r/jamesbrink/opengl/) [![Docker Pulls](https://img.shields.io/docker/pulls/jamesbrink/opengl.svg)](https://hub.docker.com/r/jamesbrink/opengl/) [![Docker Stars](https://img.shields.io/docker/stars/jamesbrink/opengl.svg)](https://hub.docker.com/r/jamesbrink/opengl/) [![](https://images.microbadger.com/badges/image/jamesbrink/opengl.svg)](https://microbadger.com/images/jamesbrink/opengl "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/jamesbrink/opengl.svg)](https://microbadger.com/images/jamesbrink/opengl "Get your own version badge on microbadger.com")
4+
5+
6+
## About
7+
8+
Minimal Docker container bundled with the Mesa 3D Gallium Drivers: [LLVMpipe][mesa-llvm] & [OpenSWR][openswr], enabling OpenGL support inside a Docker container without the need for a GPU.
9+
10+
11+
## Features
12+
13+
* Alpine Linux 3.7
14+
* LLVMpipe Driver (Mesa 18.0.1)
15+
* OpenSWR Driver (Mesa 18.0.1)
16+
* OSMesa Interface (Mesa 18.0.1)
17+
* softpipe - Reference Gallium software driver
18+
* swrast - Legacy Mesa software rasterizer
19+
* Xvfb - X Virtual Frame Buffer
20+
21+
## Docker Images
22+
23+
| Image | Description |
24+
| ------------------------- | ----------------------------------------------------------------------- |
25+
| `jamesbrink/opengl` | Minimal image, good to extend `FROM` |
26+
| `jamesbrink/opengl:demos` | Same image with added mesa3d demos such as `glxinfo`, `glxgears`, etc.. |
27+
28+
## Usage
29+
30+
I build this image primarily to extnend from for other projects, but below are some simple examples. This image is already loaded with a trivial entrypoint script.
31+
32+
Extending from this image.
33+
34+
```Dockerfile
35+
FROM jamesbrink/php:7.2
36+
COPY ./MyAppOpenGLApp /AnywhereMyHeartDesires
37+
RUN apk add --update my-deps...
38+
```
39+
40+
Running a simple glxgears test.
41+
42+
```shell
43+
docker run jamesbrink/opengl:demos glxgears -info
44+
```
45+
46+
Running glxgears with OpenSWR
47+
48+
```shell
49+
docker run jamesbrink/opengl:demos -e GALLIUM_DRIVER=swr glxgears -info
50+
```
51+
52+
## Environment Variables
53+
54+
### High level settings
55+
56+
| Variable | Default Value | Description |
57+
| ----------------------- | -------------- | -------------------------------------------------------------- |
58+
| `XVFB_WHD` | `1920x1080x24` | Xvfb demensions and bit depth. |
59+
| `DISPLAY` | `:99` | X Display number. |
60+
| `LIBGL_ALWAYS_SOFTWARE` | `1` | Forces Mesa 3D to always use software rendering. |
61+
| `GALLIUM_DRIVER` | `llvmpipe` | Sets OpenGL Driver `llvmpipe`, `swr`, `softpipe`, and `swrast` |
62+
63+
### Lower level settings / tweaks
64+
65+
| Variable | Default Value | Description |
66+
| ---------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
67+
| `LP_NO_RAST` | `false` | LLVMpipe - If set LLVMpipe will no-op rasterization |
68+
| `LP_DEBUG` | `""` | LLVMpipe - A comma-separated list of debug options is accepted |
69+
| `LP_PERF` | `""` | LLVMpipe - A comma-separated list of options to selectively no-op various parts of the driver. |
70+
| `LP_NUM_THREADS` | `""` | LLVMpipe - An integer indicating how many threads to use for rendering. Zero (`0`) turns off threading completely. The default value is the number of CPU cores present. |
71+
72+
73+
74+
75+
76+
77+
[openswr]: http://openswr.org/
78+
[mesa-llvm]: https://www.mesa3d.org/llvmpipe.html
79+
80+
81+

demos/Dockerfile

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Mesa3D Software Drivers
2+
#
3+
# VERSION 18.0.1
4+
5+
FROM alpine:3.7
6+
7+
# Build arguments.
8+
ARG VCS_REF
9+
ARG BUILD_DATE
10+
ARG MESA_DEMOS="true"
11+
12+
# Labels / Metadata.
13+
LABEL maintainer="James Brink, [email protected]" \
14+
decription="Mesa3D Software Drivers" \
15+
version="18.0.1" \
16+
org.label-schema.name="Mesa3D-Software-Drivers" \
17+
org.label-schema.build-date=$BUILD_DATE \
18+
org.label-schema.vcs-ref=$VCS_REF \
19+
org.label-schema.vcs-url="https://github.com/jamesbrink/docker-gource" \
20+
org.label-schema.schema-version="1.0.0-rc1"
21+
22+
# Install all needed deps and compile the mesa llvmpipe driver from source.
23+
RUN set -xe; \
24+
apk --update add --no-cache --virtual .runtime-deps xvfb llvm5-libs xdpyinfo; \
25+
apk add --no-cache --virtual .build-deps llvm-dev build-base zlib-dev glproto xorg-server-dev python-dev; \
26+
mkdir -p /var/tmp/build; \
27+
cd /var/tmp/build; \
28+
wget "https://mesa.freedesktop.org/archive/mesa-18.0.1.tar.gz"; \
29+
tar xfv mesa-18.0.1.tar.gz; \
30+
rm mesa-18.0.1.tar.gz; \
31+
cd mesa-18.0.1; \
32+
./configure --enable-glx=gallium-xlib --with-gallium-drivers=swrast,swr --disable-dri --disable-gbm --disable-egl --enable-gallium-osmesa --prefix=/usr/local; \
33+
make; \
34+
make install; \
35+
cd .. ; \
36+
rm -rf mesa-18.0.1; \
37+
if [ "${MESA_DEMOS}" == "true" ]; then \
38+
apk add --no-cache --virtual .mesa-demos-runtime-deps glu glew \
39+
&& apk add --no-cache --virtual .mesa-demos-build-deps glew-dev freeglut-dev \
40+
&& wget "ftp://ftp.freedesktop.org/pub/mesa/demos/mesa-demos-8.4.0.tar.gz" \
41+
&& tar xfv mesa-demos-8.4.0.tar.gz \
42+
&& rm mesa-demos-8.4.0.tar.gz \
43+
&& cd mesa-demos-8.4.0 \
44+
&& ./configure --prefix=/usr/local \
45+
&& make \
46+
&& make install \
47+
&& cd .. \
48+
&& rm -rf mesa-demos-8.4.0 \
49+
&& apk del .mesa-demos-build-deps; \
50+
fi; \
51+
apk del .build-deps;
52+
53+
# Copy our entrypoint into the container.
54+
COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh
55+
56+
# Setup our environment variables.
57+
ENV XVFB_WHD="1920x1080x24"\
58+
DISPLAY=":99" \
59+
LIBGL_ALWAYS_SOFTWARE="1" \
60+
GALLIUM_DRIVER="llvmpipe" \
61+
LP_NO_RAST="false" \
62+
LP_DEBUG="" \
63+
LP_PERF="" \
64+
LP_NUM_THREADS=""
65+
66+
# Set the default command.
67+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

demos/entrypoint.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
if [ $# -eq 0 ]; then
4+
echo "No command was given to run, exiting."
5+
exit 1
6+
else
7+
# Start Xvfb
8+
echo "Starting Xvfb"
9+
Xvfb :99 -ac -screen 0 "$XVFB_WHD" -nolisten tcp &
10+
Xvfb_pid="$!"
11+
echo "Waiting for Xvfb to be ready..."
12+
while ! xdpyinfo -display "${DISPLAY}" > /dev/null 2>&1; do
13+
sleep 0.1
14+
done
15+
# Execute passed command.
16+
"$@" &
17+
cmd_pid=$!
18+
trap "echo 'Stopping'; kill -SIGTERM $Xvfb_pid $cmd_pid" SIGINT SIGTERM
19+
# Wait for process to end.
20+
while kill -0 $Xvfb_pid $cmd_pid > /dev/null 2>&1; do
21+
wait
22+
done
23+
fi

demos/hooks/build

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
# $IMAGE_NAME var is injected into the build so the tag is correct.
4+
5+
echo "Build hook running"
6+
docker build --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
7+
--build-arg VCS_REF=`git rev-parse --short HEAD` \
8+
-t $IMAGE_NAME .

entrypoint.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
if [ $# -eq 0 ]; then
4+
echo "No command was given to run, exiting."
5+
exit 1
6+
else
7+
# Start Xvfb
8+
echo "Starting Xvfb"
9+
Xvfb :99 -ac -screen 0 "$XVFB_WHD" -nolisten tcp &
10+
Xvfb_pid="$!"
11+
echo "Waiting for Xvfb to be ready..."
12+
while ! xdpyinfo -display "${DISPLAY}" > /dev/null 2>&1; do
13+
sleep 0.1
14+
done
15+
# Execute passed command.
16+
"$@" &
17+
cmd_pid=$!
18+
trap "echo 'Stopping'; kill -SIGTERM $Xvfb_pid $cmd_pid" SIGINT SIGTERM
19+
# Wait for process to end.
20+
while kill -0 $Xvfb_pid $cmd_pid > /dev/null 2>&1; do
21+
wait
22+
done
23+
fi

hooks/build

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
# $IMAGE_NAME var is injected into the build so the tag is correct.
4+
5+
echo "Build hook running"
6+
docker build --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
7+
--build-arg VCS_REF=`git rev-parse --short HEAD` \
8+
-t $IMAGE_NAME .

0 commit comments

Comments
 (0)