Skip to content

Commit

Permalink
Merge pull request #2008 from mikedh/feat/prune
Browse files Browse the repository at this point in the history
Release: Reduce Requirements
  • Loading branch information
mikedh authored Aug 24, 2023
2 parents bad28b4 + 475f921 commit a2f89a6
Show file tree
Hide file tree
Showing 8 changed files with 256 additions and 282 deletions.
38 changes: 22 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ LABEL maintainer="mikedh@kerfed.com"
# Install helper script to PATH.
COPY --chmod=755 docker/trimesh-setup /usr/local/bin/

# Create a local non-root user.
RUN useradd -m -s /bin/bash user
# Create a non-root user with `uid=499`.
RUN useradd -m -u 499 -s /bin/bash user

# Required for Python to be able to find libembree.
ENV LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
Expand All @@ -20,14 +20,18 @@ FROM base AS build
RUN trimesh-setup --install build

# copy in essential files
COPY --chown=user:user trimesh/ /home/user/trimesh
COPY --chown=user:user setup.py /home/user/
COPY --chown=499 trimesh/ /home/user/trimesh
COPY --chown=499 setup.py /home/user/

# switch to non-root user
USER user

# install trimesh into .local
RUN pip install /home/user[all]
# then delete any included test directories
# and remove Cython after all the building is complete
RUN pip install /home/user[all] && \
find /home/user/.local -type d -name tests -prune -exec rm -rf {} \; && \
pip uninstall -y cython

####################################
### Build output image most things should run on
Expand All @@ -38,7 +42,7 @@ USER user
WORKDIR /home/user

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

# Set environment variables for software rendering.
ENV XVFB_WHD="1920x1080x24"\
Expand All @@ -51,19 +55,21 @@ ENV XVFB_WHD="1920x1080x24"\
FROM output AS tests

# copy in tests and supporting files
COPY --chown=user:user tests ./tests/
COPY --chown=user:user models ./models/
COPY --chown=user:user setup.py .
COPY --chown=499 tests ./tests/
COPY --chown=499 trimesh ./trimesh/
COPY --chown=499 models ./models/
COPY --chown=499 setup.py .
COPY --chown=499 pyproject.toml .

# codecov looks at the git history
COPY --chown=user:user ./.git ./.git/
COPY --chown=499 ./.git ./.git/

USER root
RUN trimesh-setup --install=test,gltf_validator,llvmpipe,binvox
USER user

# install things like pytest
RUN pip install `python setup.py --list-test`
RUN pip install -e .[all,easy,recommends,test]

# run pytest wrapped with xvfb for simple viewer tests
RUN xvfb-run pytest --cov=trimesh \
Expand All @@ -86,11 +92,11 @@ USER root
RUN trimesh-setup --install docs
USER user

COPY --chown=user:user README.md .
COPY --chown=user:user docs ./docs/
COPY --chown=user:user examples ./examples/
COPY --chown=user:user models ./models/
COPY --chown=user:user trimesh ./trimesh/
COPY --chown=499 README.md .
COPY --chown=499 docs ./docs/
COPY --chown=499 examples ./examples/
COPY --chown=499 models ./models/
COPY --chown=499 trimesh ./trimesh/

WORKDIR /home/user/docs
RUN make
Expand Down
Loading

0 comments on commit a2f89a6

Please sign in to comment.