Last active
May 17, 2024 06:47
-
-
Save neuro-sys/271a61eb3ca0436a79c967572696f2c9 to your computer and use it in GitHub Desktop.
Dockerfile for headless-gl. You also need to run Docker container in "privileged" mode, assign X11 auth volume on the container, and possibly give Xauth access for call from outside.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build stage | |
FROM nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 as builder | |
# Install node 14.0 | |
RUN apt-get update -y && \ | |
apt-get install -y curl gnupg ca-certificates && \ | |
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \ | |
apt-get install -y nodejs | |
# See: https://github.com/stackgl/headless-gl#ubuntudebian | |
RUN apt-get update -y && \ | |
apt-get install -y build-essential python libxi-dev libglu-dev libglew-dev pkg-config git | |
WORKDIR /build | |
COPY package*.json . | |
COPY my-threejs-app my-threejs-app | |
RUN npm install --production | |
COPY tsconfig.json ./ | |
COPY src src | |
RUN npm run build | |
# Build headless-gl natively as the prebuilt binary is not compatible | |
# See https://github.com/stackgl/headless-gl/issues/65#issuecomment-252742795 | |
RUN git clone https://github.com/stackgl/headless-gl.git && \ | |
cd headless-gl && \ | |
git submodule init && \ | |
git submodule update && \ | |
npm install && \ | |
npm run rebuild | |
# We will later copy headless-gl/build/Release/webgl.node into runtime layer | |
# Runtime stage, install and copy only what's needed to run | |
FROM nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 | |
# Install node 14.0 | |
RUN apt-get update -y && \ | |
apt-get install -y curl gnupg ca-certificates && \ | |
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \ | |
apt-get install -y nodejs | |
# See: https://github.com/stackgl/headless-gl#ubuntudebian | |
RUN apt-get update -y && \ | |
apt-get install -y build-essential python libxi-dev libglu-dev libglew-dev pkg-config git | |
EXPOSE 80 | |
WORKDIR /app | |
COPY fonts fonts | |
COPY --from=builder /build/node_modules node_modules | |
COPY --from=builder /build/tsconfig.json tsconfig.json | |
COPY --from=builder /build/dist dist | |
COPY --from=builder /build/package.json package.json | |
COPY --from=builder /build/headless-gl/build/Release/webgl.node node_modules/gl/build/Release/webgl.node | |
ENV DISPLAY :0 | |
CMD [ "node", "dist/src/index.js" ] |
@neuro-sys Thank you a lot! I was able to link headless-gl with egl provided by nvidia image. I removed x-server from our host, which simplified our infrastructure
@stepancar Glad to be helpful, and good to hear you were able to use EGL. Feel free to share links or describe how you did it in case someone else finds their way here with the same need.
Sure!
This is a comment with explanation stackgl/headless-gl#116 (comment)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@stepancar that is the part in the description:
And I don't remember it all by memory and takes long to explain. So essentially it is how and why X has a server client model. They talk via sockets (in this case by a named pipe, in /var folder, hence the volume mounting) despite being on the same machine (i.e. the host with the docker container/pod).
I ran it with GPU on production, software rendering for test containers. In the end we wrote a non-javascript based application to do the rendering.