add opengl image

This commit is contained in:
Yves-Marie Haussonne 2024-09-30 12:54:55 +02:00
parent 0de9e699b6
commit ff897425c5
3 changed files with 174 additions and 0 deletions

41
opengl/.gitlab-ci.yaml Normal file
View File

@ -0,0 +1,41 @@
default:
image: docker:20.10.16
services:
- docker:20.10.16-dind
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin
stages:
- build
- release
variables:
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
OPENGL_CONTAINER_CURRENT_IMAGE: $CI_REGISTRY_IMAGE/opengl:$CI_COMMIT_REF_SLUG
OPENGL_CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE/opengl:latest
build_opengl:
stage: build
script:
- cd opengl
- docker build --pull -t $OPENGL_CONTAINER_CURRENT_IMAGE .
- docker push $OPENGL_CONTAINER_CURRENT_IMAGE
rules:
- changes:
- opengl/**/*
release-image_opengl:
stage: release
script:
- cd opengl
- docker pull $OPENGL_CONTAINER_CURRENT_IMAGE
- docker tag $OPENGL_CONTAINER_CURRENT_IMAGE $OPENGL_CONTAINER_RELEASE_IMAGE
- docker push $OPENGL_CONTAINER_RELEASE_IMAGE
rules:
- if: $CI_COMMIT_BRANCH == "main"
- changes:
- opengl/**/*

133
opengl/Dockerfile Normal file
View File

@ -0,0 +1,133 @@
# Base Docker Image
ARG BASE_IMAGE=alpine:latest
FROM ${BASE_IMAGE} as builder
# Install all needed build deps for Mesa3D
ARG LLVM_VERSION=18
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 \
llvm-libunwind-dev \
eudev-libs \
makedepend \
py3-meson-python \
py-mako \
py3-libxml2 \
py3-mako \
py3-yaml \
python3 \
python3-dev \
talloc-dev \
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=24.2
RUN set -xe; \
mkdir -p /var/tmp/build; \
cd /var/tmp/build/; \
git clone --depth=1 --branch=${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; \
galium_drivers=softpipe,llvmpipe; \
meson setup \
--buildtype=${BUILD_TYPE} \
--prefix=/usr/local \
--sysconfdir=/etc \
-D b_ndebug=true \
-D gallium-nine=false \
-D gles1=disabled \
-D gles2=disabled \
-D opengl=true \
-D dri-drivers-path=/usr/local/lib/xorg/modules/dri \
-D dri3=disabled \
-D egl=disabled \
-D gallium-drivers="$galium_drivers" \
-D gbm=disabled \
-D glx=xlib \
-D llvm=enabled \
-D lmsensors=disabled \
-D optimization=${BUILD_OPTIMIZATION} \
-D osmesa=true \
-D platforms=x11 \
-D shared-glapi=enabled \
-D shared-llvm=enabled \
-D vulkan-drivers= \
build/; \
ninja -C build/ -j $(getconf _NPROCESSORS_ONLN); \
ninja -C build/ install
# Copy our entrypoint into the container.
COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh
# Create fresh image from alpine
ARG BASE_IMAGE=alpine:latest
FROM ${BASE_IMAGE}
# Copy the Mesa build & entrypoint script from previous stage
COPY --from=builder /usr/local /usr/local
# Install runtime dependencies for Mesa and link xorg dri modules
ARG LLVM_VERSION=18
RUN set -xe; \
apk --update add --no-cache \
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 \
DISPLAY=":99" \
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="" \
MESA_VERSION="${MESA_VERSION}" \
XVFB_WHD="640x480x8"
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

0
opengl/entrypoint.sh Normal file
View File