Skip to content

Commit 81a9dc5

Browse files
committed
Refactor build to use Makefile
1 parent 435bb3e commit 81a9dc5

File tree

5 files changed

+141
-57
lines changed

5 files changed

+141
-57
lines changed

.dockerignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
.git
22
.gitignore
33
.travis.yml
4-
README.md
5-
LICENSE
6-
hooks
74
Dockerfile
5+
hooks
6+
LICENSE
7+
README.md
8+
temp

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
temp

Dockerfile

+78-49
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,96 @@
11
# Mesa3D Software Drivers
2-
#
3-
# VERSION 18.0.1
42

5-
FROM alpine:3.7
3+
FROM alpine:3.10 as builder
64

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"
5+
# Install all needed build deps for Mesa
6+
RUN set -xe; \
7+
apk add --no-cache --virtual .build-deps \
8+
autoconf \
9+
automake \
10+
bison \
11+
build-base \
12+
expat-dev \
13+
flex \
14+
gettext \
15+
git \
16+
glproto \
17+
libtool \
18+
llvm7 \
19+
llvm7-dev \
20+
py-mako \
21+
xorg-server-dev python-dev \
22+
zlib-dev;
2123

22-
# Install all needed deps and compile the mesa llvmpipe driver from source.
24+
# Clone Mesa source repo. (this step caches)
25+
# Due to ongoing packaging issues we build from git vs tar packages
26+
# Refer to https://bugs.freedesktop.org/show_bug.cgi?id=107865
2327
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; \
2628
mkdir -p /var/tmp/build; \
2729
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;
30+
git clone https://gitlab.freedesktop.org/mesa/mesa.git;
31+
32+
# Build Mesa from source.
33+
ARG MESA_VERSION
34+
RUN set -xe; \
35+
cd /var/tmp/build/mesa; \
36+
git checkout mesa-${MESA_VERSION}; \
37+
libtoolize; \
38+
autoreconf --install; \
39+
./configure \
40+
--enable-glx=gallium-xlib \
41+
--with-gallium-drivers=swrast,swr \
42+
--disable-dri \
43+
--disable-gbm \
44+
--disable-egl \
45+
--enable-gallium-osmesa \
46+
--enable-autotools \
47+
--enable-llvm \
48+
--with-llvm-prefix=/usr/lib/llvm7/ \
49+
--prefix=/usr/local; \
50+
make -j$(getconf _NPROCESSORS_ONLN); \
51+
make install;
5252

5353
# Copy our entrypoint into the container.
5454
COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh
5555

56+
# Create fresh image from alpine
57+
FROM alpine:3.10
58+
59+
# Install runtime dependencies for Mesa
60+
RUN set -xe; \
61+
apk --update add --no-cache --virtual .runtime-deps \
62+
expat \
63+
llvm7-libs \
64+
xdpyinfo \
65+
xvfb;
66+
67+
# Copy the Mesa build & entrypoint script from previous stage
68+
COPY --from=builder /usr/local /usr/local
69+
70+
# Labels / Metadata.
71+
ARG VCS_REF
72+
ARG BUILD_DATE
73+
ARG MESA_DEMOS
74+
ARG MESA_VERSION
75+
LABEL maintainer="James Brink, [email protected]" \
76+
org.label-schema.decription="Mesa3D Software Drivers" \
77+
org.label-schema.version="${MESA_VERSION}" \
78+
org.label-schema.name="Mesa3D-Software-Drivers" \
79+
org.label-schema.build-date="${BUILD_DATE}" \
80+
org.label-schema.vcs-ref="${VCS_REF}" \
81+
org.label-schema.vcs-url="https://github.com/utensils/docker-opengl" \
82+
org.label-schema.schema-version="1.0.0-rc1"
83+
5684
# Setup our environment variables.
57-
ENV XVFB_WHD="1920x1080x24"\
58-
DISPLAY=":99" \
59-
LIBGL_ALWAYS_SOFTWARE="1" \
85+
ENV DISPLAY=":99" \
6086
GALLIUM_DRIVER="llvmpipe" \
61-
LP_NO_RAST="false" \
87+
LIBGL_ALWAYS_SOFTWARE="1" \
6288
LP_DEBUG="" \
89+
LP_NO_RAST="false" \
90+
LP_NUM_THREADS="" \
6391
LP_PERF="" \
64-
LP_NUM_THREADS=""
92+
MESA_VERSION="${MESA_VERSION}" \
93+
XVFB_WHD="1920x1080x24"
6594

6695
# Set the default command.
6796
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

Makefile

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# !/usr/bin/make - f
2+
3+
SHELL := /usr/bin/env bash
4+
DOCKER_NAMESPACE ?= jamesbrink
5+
IMAGE_NAME ?= opengl
6+
VERSION := $(shell git describe --tags --abbrev=0 2>/dev/null || git rev-parse --abbrev-ref HEAD)
7+
VCS_REF := $(shell git rev-parse --short HEAD)
8+
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
9+
ARCH := $(shell uname -m)
10+
RELEASES := 18.2.8 18.3.6 19.0.8
11+
LATEST_TAG := 19.0.8
12+
STABLE_TAG := 19.0.8
13+
14+
# Default target is to build all defined Mesa releases.
15+
.PHONY: default
16+
default: 19.0.8 tag-latest
17+
18+
.PHONY: all tag-latest
19+
all: $(RELEASES)
20+
21+
# Build base images for all releases.
22+
.PHONY: $(RELEASES)
23+
$(RELEASES):
24+
docker build \
25+
--build-arg BUILD_DATE=$(BUILD_DATE) \
26+
--build-arg VCS_REF=$(VCS_REF) \
27+
--build-arg MESA_VERSION=$(@) \
28+
--tag $(DOCKER_NAMESPACE)/$(IMAGE_NAME):$(@) \
29+
--tag $(DOCKER_NAMESPACE)/$(IMAGE_NAME):$(@)-$(VCS_REF) \
30+
--tag $(DOCKER_NAMESPACE)/$(IMAGE_NAME):$(@)-$(VERSION) \
31+
--file Dockerfile .; \
32+
33+
# Tag our latest release
34+
.PHONY: tag-latest
35+
tag-latest:
36+
docker tag $(DOCKER_NAMESPACE)/$(IMAGE_NAME):$(LATEST_TAG) $(DOCKER_NAMESPACE)/$(IMAGE_NAME):latest
37+
38+
# Tag our stable release
39+
.PHONY: tag-stable
40+
tag-stable:
41+
docker tag $(DOCKER_NAMESPACE)/$(IMAGE_NAME):$(STABLE_TAG) $(DOCKER_NAMESPACE)/$(IMAGE_NAME):stable
42+
43+

README.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ Minimal Docker container bundled with the Mesa 3D Gallium Drivers: [LLVMpipe][me
1010

1111
## Features
1212

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)
13+
* Alpine Linux 3.10
14+
* LLVMpipe Driver (Mesa 19.0.8)
15+
* OpenSWR Driver (Mesa 19.0.8)
16+
* OSMesa Interface (Mesa 19.0.8)
1717
* softpipe - Reference Gallium software driver
1818
* swrast - Legacy Mesa software rasterizer
1919
* Xvfb - X Virtual Frame Buffer
@@ -25,14 +25,24 @@ Minimal Docker container bundled with the Mesa 3D Gallium Drivers: [LLVMpipe][me
2525
| `jamesbrink/opengl` | Minimal image, good to extend `FROM` |
2626
| `jamesbrink/opengl:demos` | Same image with added mesa3d demos such as `glxinfo`, `glxgears`, etc.. |
2727

28+
29+
## Building
30+
31+
This image can be built using the supplied Makefile
32+
33+
```shell
34+
make
35+
```
36+
37+
2838
## Usage
2939

3040
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.
3141

3242
Extending from this image.
3343

3444
```Dockerfile
35-
FROM jamesbrink/opengl:18.0.1
45+
FROM jamesbrink/opengl:19.0.8
3646
COPY ./MyAppOpenGLApp /AnywhereMyHeartDesires
3747
RUN apk add --update my-deps...
3848
```

0 commit comments

Comments
 (0)