Skip to content

Commit

Permalink
try a vanilla debian image
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedh committed Aug 16, 2024
1 parent b7609f1 commit e9e4063
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
43 changes: 17 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,41 @@
FROM python:3.12-slim-bookworm AS base
# use a vanilla Debian base image
FROM debian:trixie-slim AS base
LABEL maintainer="[email protected]"

# Install helper script to PATH.
COPY --chmod=755 docker/trimesh-setup /usr/local/bin/

# Create a non-root user with `uid=499`.
RUN useradd -m -u 499 -s /bin/bash user
RUN useradd -m -u 499 -s /bin/bash user && \
apt-get update && \
apt-get install --no-install-recommends -qq -y python3.12-venv && \
apt-get clean -y

# Required for Python to be able to find libembree.
ENV LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
USER user

WORKDIR /home/user
RUN python3.12 -m venv venv

# So scripts installed from pip are in $PATH
ENV PATH="/home/user/.local/bin:$PATH"
ENV PATH="/home/user/venv/bin:$PATH"

# Install helper script to PATH.
COPY --chmod=755 docker/trimesh-setup /home/user/venv/bin

#######################################
## install things that need building
FROM base AS build

# install build essentials for compiling stuff
RUN trimesh-setup --install build

# copy in essential files
COPY --chown=499 trimesh/ /home/user/trimesh
COPY --chown=499 pyproject.toml /home/user/

# switch to non-root user
USER user

# install trimesh into .local
RUN pip install --user /home/user[easy]
RUN pip install /home/user[easy]

####################################
### Build output image most things should run on
FROM base AS output

# switch to non-root user
USER user
WORKDIR /home/user

# just copy over the results of the compiled packages
COPY --chown=499 --from=build /home/user/.local /home/user/.local

# Set environment variables for software rendering.
ENV XVFB_WHD="1920x1080x24"\
DISPLAY=":99" \
LIBGL_ALWAYS_SOFTWARE="1" \
GALLIUM_DRIVER="llvmpipe"
COPY --chown=499 --from=build /home/user/venv /home/user/venv

###############################
#### Run Unit Tests
Expand Down
3 changes: 0 additions & 3 deletions docker/trimesh-setup
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,13 @@ config_json = """
"pandoc"
],
"llvmpipe": [
"libgl1-mesa-glx",
"libgl1-mesa-dri",
"xvfb",
"xauth",
"ca-certificates",
"freeglut3-dev"
],
"test": [
"blender",
"openscad",
"curl",
"git"
],
Expand Down
6 changes: 6 additions & 0 deletions examples/docker/render/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ RUN trimesh-setup --install llvmpipe
# go back to the unprivileged user
USER user

# Set environment variables for software rendering.
ENV XVFB_WHD="1920x1080x24"\
DISPLAY=":99" \
LIBGL_ALWAYS_SOFTWARE="1" \
GALLIUM_DRIVER="llvmpipe"

# copy our example file which renders a sphere
COPY render.py .

Expand Down

0 comments on commit e9e4063

Please sign in to comment.