4 Commits

9 changed files with 149 additions and 119 deletions
@@ -1,24 +1,23 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build BlenderDocker" type="docker-deploy" factoryName="dockerfile" server-name="Docker"> <configuration default="false" name="Build Blender" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile"> <deployment type="dockerfile">
<settings> <settings>
<option name="imageTag" value="stilobique/blender:5.1.2" /> <option name="imageTag" value="stilobique/blender:3.4.0" />
<option name="buildArgs"> <option name="buildArgs">
<list> <list>
<DockerEnvVarImpl> <DockerEnvVarImpl>
<option name="name" value="b3d_vs_major" /> <option name="name" value="b3d_vs_major" />
<option name="value" value="5.1" /> <option name="value" value="3.4" />
</DockerEnvVarImpl> </DockerEnvVarImpl>
<DockerEnvVarImpl> <DockerEnvVarImpl>
<option name="name" value="b3d_vs_minor" /> <option name="name" value="b3d_vs_minor" />
<option name="value" value="2" /> <option name="value" value="0" />
</DockerEnvVarImpl> </DockerEnvVarImpl>
</list> </list>
</option> </option>
<option name="buildCliOptions" value="--debug" />
<option name="buildOnly" value="true" /> <option name="buildOnly" value="true" />
<option name="containerName" value="blender-latest" /> <option name="containerName" value="blender-latest" />
<option name="sourceFilePath" value="Dockerfile" /> <option name="sourceFilePath" value="image/Dockerfile-build-blender" />
<option name="volumeBindings"> <option name="volumeBindings">
<list> <list>
<DockerVolumeBindingImpl> <DockerVolumeBindingImpl>
@@ -29,7 +28,6 @@
</option> </option>
</settings> </settings>
</deployment> </deployment>
<EXTENSION ID="com.jetbrains.rider.docker.debug" isFastModeEnabled="true" isSslEnabled="false" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
</component> </component>
+23
View File
@@ -0,0 +1,23 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Make Blender Cache" type="PythonConfigurationType" factoryName="Python">
<module name="blender-docker" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/generate-image-repo.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>
-97
View File
@@ -1,97 +0,0 @@
FROM ubuntu:25.04 AS b3dock
# Setup all software version request
ARG b3d_vs_major=5.1
ARG b3d_vs_minor=0
LABEL Author="stilobique"
LABEL Title="Blender Docker for Unit Test"
#ENV TZ=Europe/Paris
#RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
## 01. Start First stage to build blender
# Install dependencies
RUN apt-get update && apt-get install -y \
git \
git-lfs \
python3 \
build-essential \
subversion \
cmake \
libx11-dev \
libxxf86vm-dev \
libxcursor-dev \
libxi-dev \
libxrandr-dev \
libxinerama-dev \
libegl-dev \
libwayland-dev \
wayland-protocols \
libxkbcommon-dev \
libdbus-1-dev \
linux-libc-dev
# Compile Blender
RUN git clone --depth 1 --branch v${b3d_vs_major}.${b3d_vs_minor} \
https://projects.blender.org/blender/blender.git /opt/blender
RUN cd /opt/blender && make update
RUN cd /opt/blender && make -j$(nproc)
## 02. Collecte all dependencies
FROM b3dock AS collector
# Rassemble toutes les .so des precompiled libs dans un dossier plat
# -not -type d : ignore les dossiers
# cp -P : préserve les symlinks relatifs (libFoo.so -> libFoo.so.1.0)
RUN mkdir -p /collected-libs && \
find /opt/blender/lib/linux_x64 \
-name "*.so*" \
-not -type d \
-exec cp -P {} /collected-libs/ \;
## 03. Build optimissed image
## Setup a Multistage optimisation
FROM ubuntu:25.04
RUN apt-get update && apt-get install -y \
libx11-6 \
libxi6 \
libxxf86vm1 \
libxrender1 \
libxrandr2 \
libxinerama1 \
libxcursor1 \
libxfixes3 \
libxkbcommon0 \
libwayland-client0 \
libwayland-egl1 \
libegl1 \
libgl1 \
libdbus-1-3 \
libxcb1 \
libtbb12 \
libopenal1 \
libsm6 \
libice6 \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -m -s /bin/bash bld
COPY --from=b3dock /opt/build_linux/bin/blender /usr/local/bin/blender
COPY --from=collector /collected-libs /usr/local/lib/blender
RUN echo "/usr/local/lib/blender" > /etc/ld.so.conf.d/blender.conf \
&& ldconfig
ARG b3d_vs_major
ENV B3D_ADDON_PATH="/home/bld/.config/blender/${b3d_vs_major}/scripts/addons"
USER bld
# Working Directory setup
WORKDIR /home/bld
ENTRYPOINT ["/usr/local/bin/blender"]
CMD ["--version"]
+2 -6
View File
@@ -1,5 +1,6 @@
[![Blender](https://img.shields.io/badge/blender-5.1.2-%23F5792A.svg?style=flat&logo=blender&logoColor=white)](https://www.blender.org/download/) [![Blender](https://img.shields.io/badge/blender-3.10.0-%23F5792A.svg?style=flat&logo=blender&logoColor=white)](https://www.blender.org/download/)
[![pipeline status](https://gitlab.com/stilobique/blender-docker/badges/main/pipeline.svg)](https://gitlab.com/stilobique/blender-docker/-/commits/main) [![pipeline status](https://gitlab.com/stilobique/blender-docker/badges/main/pipeline.svg)](https://gitlab.com/stilobique/blender-docker/-/commits/main)
[![Python Version](https://img.shields.io/badge/python-3.10-brightgreen)](https://www.python.org/)
# Blender Docker # Blender Docker
@@ -26,8 +27,3 @@ Call this function with blender inside this container
#!/bin/sh #!/bin/sh
/opt/blender/blender --background --python "install.py" /opt/blender/blender --background --python "install.py"
```` ````
# Check Image build
```shell
docker run --rm stilobique/blender:5.1.2 blender --version
```
-7
View File
@@ -1,7 +0,0 @@
#!/usr/bin/env bash
set -e
LIB_PATHS="$(find /opt/blender-libs -type d -name lib | paste -sd: -)"
export LD_LIBRARY_PATH="${LIB_PATHS}:${LD_LIBRARY_PATH}"
exec /usr/local/bin/blender "$@"
+41
View File
@@ -0,0 +1,41 @@
import docker
import os
def get_repo_container():
"""
- Check if a blender/csv image local exist
- If yes, check if a container exist
:return:
"""
client = docker.from_env()
if os.environ.get('docker_hub_password'):
client.login(username=os.environ['docker_hub_user'], password=os.environ['docker_hub_password'])
dk_tags = 'stilobique/csv'
dk_container_name = 'blender-cache-repo'
dk_images_local = client.images.list(name=dk_tags)
dk_containers_local = client.containers.list(filters={'label': dk_container_name})
volumes = ["/scripts/:/scripts"]
commandes = ['bash', '/scripts/set_all_repository.sh']
if dk_containers_local:
# The container cache exist, used-it
client.containers.run(image=dk_tags, name=dk_container_name)
pass
elif dk_images_local:
# No container, but the image are build, start a container cache
client.containers.run(image=dk_tags, name=dk_container_name)
pass
else:
# No container, no image ; build a new image and start this cache
client.images.build(path="image", dockerfile="Dockerfile-csv", tag=f'{dk_tags}:latest', rm=True)
client.containers.run(image=dk_tags, name=dk_container_name, volumes=volumes, command=commandes)
if __name__ == "__main__":
# Make or update the docker container
get_repo_container()
print('Blender repo set')
+59
View File
@@ -0,0 +1,59 @@
FROM ubuntu:22.04 AS blender
# Setup all software version request
ARG b3d_vs_major=2.90
ARG b3d_vs_minor=0
ARG subversion=63014
LABEL Author="stilobique"
LABEL Title="Blender Docker for Unit Test"
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
gcc \
git \
cmake \
libc6-dev \
libx11-dev \
subversion \
libxrandr-dev \
libxcursor-dev \
libxxf86vm-dev \
libxinerama-dev \
libglew-dev \
libxi-dev \
python3
# Debug
RUN echo Build Blender v${b3d_vs_major}.${b3d_vs_minor}
ADD . /opt/blender-git
# Compile Blender
RUN cd /opt/blender-git/ \
&& git checkout v${b3d_vs_major}.${b3d_vs_minor} \
&& git config --global user.email "contact@aurelien-vaillant.net" \
&& git config --global user.name "Aurelien Vaillant" \
&& mkdir /opt/blender-git/lib \
&& cd /opt/blender-git/lib \
&& svn checkout -r${subversion} \
&& make
# Setup a Multistage optimisation
FROM ubuntu:22.04
COPY --from=blender /opt/blender-git/build_linux/bin /opt/blender
ARG b3d_vs_major
ENV B3D_ADDON_PATH "$HOME/.config/blender/${b3d_vs_major}/scripts/addons"
RUN apt-get update && apt-get install -y \
libxi6 \
libxxf86vm1 \
libxrender1 \
libgl1-mesa-glx
# Working Directory setup
WORKDIR /
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
echo "------------------------------";
echo " > Get the Blender repository";
mkdir -p /opt/blender-git/lib
cd /opt.blender-git/lib || exit 1
git clone https://projects.blender.org/blender/blender.git
echo "------------------------------";
echo " > Get all Blender submodule";
cd /opt/blender-git/blender || exit 1
git submodule update --init --recursive
echo "------------------------------";
echo " > Get the all lib Blender (svn)";
cd /opt/blender-git/lib || exit 1
svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/linux_centos7_x86_64