-
Notifications
You must be signed in to change notification settings - Fork 232
/
Blender.Dockerfile
124 lines (102 loc) · 3.81 KB
/
Blender.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Compiles a docker image for blender w/ "import bpy support"
#
# Compilation happens in two stages:
# 1) Compiles blender from source.
# 2) Installs previously built bpy module along with other dependencies in a fresh image.
# This two stage process reduces the size of the final image because it doesn't include
# the files and dependencies of the build process.
# #################################################################################################
# Stage 1
# #################################################################################################
FROM ubuntu:20.04 as build
ENV DEBIAN_FRONTEND=noninteractive
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
WORKDIR /blenderpy
# --- Install package dependencies
RUN apt-get update --yes --fix-missing && \
apt-get install --yes --quiet --no-install-recommends \
python3.9-dev \
build-essential \
ca-certificates \
libopenexr-dev \
cmake \
git \
libffi-dev \
libssl-dev \
libx11-dev \
libxxf86vm-dev \
libxcursor-dev \
libxi-dev \
libxrandr-dev \
libxinerama-dev \
libglew-dev \
subversion
# make python3.9 the default python
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 10 && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 10
# --- Clone and compile Blender
# RUN git clone https://git.blender.org/blender.git
RUN git clone https://github.com/blender/blender.git --branch blender-v2.93-release --depth 1
RUN mkdir lib && \
cd lib && \
svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/linux_centos7_x86_64
RUN cd blender && \
make update
# fix an annoying (no-consequence) bpy shutdown error
# see https://github.com/google-research/kubric/issues/65
COPY ./docker/cycles_free_patch.txt /blenderpy/blender
RUN cd blender && patch -p1 < /blenderpy/blender/cycles_free_patch.txt
RUN cd blender && make -j8 bpy
# #################################################################################################
# Stage 2
# #################################################################################################
FROM ubuntu:20.04
LABEL Author="kubric-team <kubric@google.com>"
LABEL Title="Blender"
ENV DEBIAN_FRONTEND=noninteractive
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
# --- Install package dependencies
# TODO: probably do not need all of them, or at least not in their dev version
RUN apt-get update --yes --fix-missing && \
apt-get install --yes --quiet --no-install-recommends --reinstall \
python3.9-dev \
python3.9-distutils \
build-essential \
# for GIF creation
imagemagick \
# OpenEXR
libopenexr-dev \
curl \
ca-certificates \
git \
libffi-dev \
libssl-dev \
libx11-dev \
libxxf86vm-dev \
libxcursor-dev \
libxi-dev \
libxrandr-dev \
libxinerama-dev \
libglew-dev \
zlib1g-dev \
# further (optional) python build dependencies
libbz2-dev \
libgdbm-dev \
liblzma-dev \
libncursesw5-dev \
libreadline-dev \
libsqlite3-dev \
#tk-dev \ # installs libpng-dev which leads to blender linking errors
uuid-dev
# make python3.9 the default python and python3
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 10 && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 10
# install pip for python 3.9
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
python3.9 get-pip.py && \
rm get-pip.py
# install bpy module within python3.9
COPY --from=build /blenderpy/build_linux_bpy/bin/bpy.so /usr/local/lib/python3.9/dist-packages/
COPY --from=build /blenderpy/lib/linux_centos7_x86_64/python/lib/python3.9/site-packages/2.93 /usr/local/lib/python3.9/dist-packages/2.93