From ff897425c5ae1a34729b6bc6963cdd7e3810568d Mon Sep 17 00:00:00 2001 From: Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com> Date: Mon, 30 Sep 2024 12:54:55 +0200 Subject: [PATCH] add opengl image --- opengl/.gitlab-ci.yaml | 41 +++++++++++++ opengl/Dockerfile | 133 +++++++++++++++++++++++++++++++++++++++++ opengl/entrypoint.sh | 0 3 files changed, 174 insertions(+) create mode 100644 opengl/.gitlab-ci.yaml create mode 100644 opengl/Dockerfile create mode 100644 opengl/entrypoint.sh diff --git a/opengl/.gitlab-ci.yaml b/opengl/.gitlab-ci.yaml new file mode 100644 index 0000000..ad0bb2f --- /dev/null +++ b/opengl/.gitlab-ci.yaml @@ -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/**/* + diff --git a/opengl/Dockerfile b/opengl/Dockerfile new file mode 100644 index 0000000..a50038d --- /dev/null +++ b/opengl/Dockerfile @@ -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"] + diff --git a/opengl/entrypoint.sh b/opengl/entrypoint.sh new file mode 100644 index 0000000..e69de29