forked from mikedh/trimesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
107 lines (82 loc) · 2.79 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
FROM python:3.11-slim-bullseye AS base
LABEL maintainer="[email protected]"
# Install the llvmpipe software renderer
# and X11 for software offscreen rendering,
# roughly 500mb of stuff.
ARG INCLUDE_X=false
# Install binary APT dependencies.
COPY --chmod=755 docker/apt-trimesh /usr/local/bin/
RUN apt-trimesh --base=true --x11=${INCLUDE_X}
# Install `embree`, Intel's fast ray checking engine
COPY docker/embree.bash /tmp/
RUN bash /tmp/embree.bash
# Create a local non-root user.
RUN useradd -m -s /bin/bash user
# Required for Python to be able to find libembree.
ENV LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
# So scripts installed from pip are in $PATH
ENV PATH="/home/user/.local/bin:$PATH"
## install things that need building
FROM base AS build
# install build-essentials
RUN apt-trimesh --build=true
# copy in essential files
COPY --chown=user:user trimesh/ /home/user/trimesh
COPY --chown=user:user setup.py /home/user/
# switch to non-root user
USER user
# install trimesh into .local
RUN pip install /home/user[all]
RUN pip install https://github.com/scopatz/pyembree/releases/download/0.1.6/pyembree-0.1.6.tar.gz
####################################
### 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 pip installs
COPY --chown=user:user --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"
###############################
#### Run Unit Tests
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=user:user docker/gltfvalidator.bash .
COPY --chown=user:user ./.git ./.git/
# install the khronos GLTF validator
RUN bash gltfvalidator.bash
# install things like pytest
RUN pip install `python setup.py --list-test`
# run tests
RUN pytest --cov=trimesh \
-p no:alldep \
-p no:cacheprovider tests
# set codecov token as a build arg to upload
ARG CODECOV_TOKEN=""
RUN curl -Os https://uploader.codecov.io/latest/linux/codecov && \
chmod +x codecov && \
./codecov -t ${CODECOV_TOKEN}
################################
### Build Sphinx Docs
FROM output AS build_docs
USER root
# install APT packages for docs
RUN apt-trimesh --docs=true
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/
WORKDIR /home/user/docs
RUN make
### Copy just the docs so we can output them
FROM scratch as docs
COPY --from=build_docs /home/user/docs/_build/html/ ./