Skip to content

Commit

Permalink
Merge pull request #2268 from mikedh/feat/trixie
Browse files Browse the repository at this point in the history
[WIP] try a vanilla debian image
  • Loading branch information
mikedh authored Aug 20, 2024
2 parents 2c20b49 + e4ed1ca commit e8a43dd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 33 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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ requires = ["setuptools >= 61.0", "wheel"]
[project]
name = "trimesh"
requires-python = ">=3.8"
version = "4.4.6"
version = "4.4.7"
authors = [{name = "Michael Dawson-Haggerty", email = "[email protected]"}]
license = {file = "LICENSE.md"}
description = "Import, export, process, analyze and view triangular meshes."
Expand Down
6 changes: 3 additions & 3 deletions trimesh/resources/templates/blender_boolean.py.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if __name__ == '__main__':
mesh_post = os.path.abspath(r'$MESH_POST')

for filename in mesh_pre: # use data.objects instead of context.scene.objects
bpy.ops.import_mesh.stl(filepath=os.path.abspath(filename))
bpy.ops.wm.stl_import(filepath=os.path.abspath(filename))

mesh = bpy.data.objects[0]
# Make sure mesh is the active object
Expand All @@ -62,6 +62,6 @@ if __name__ == '__main__':
bpy.ops.object.modifier_apply(modifier=mod.name)

delete_nonresult(bpy)
bpy.ops.export_mesh.stl(
bpy.ops.wm.stl_export(
filepath=mesh_post,
use_mesh_modifiers=True)
apply_modifiers=True)

0 comments on commit e8a43dd

Please sign in to comment.