4 Commits

12 changed files with 227 additions and 96 deletions
+38
View File
@@ -0,0 +1,38 @@
cache:
key: blender-source
paths:
- /opt/blender-git/blender # Blender git repository source
- /opt/blender-git/lib # Blender Subversion lib package
policy: pull
update-cache:
stage: .pre
cache:
key: blender-source
image: stilobique/csv:latest
script:
- mkdir -p /opt/blender-git/lib
- cd /opt/blender-git
- git clone https://projects.blender.org/blender/blender.git
- cd /opt/blender-git/blender
- git submodule update --init --recursive
- cd /opt/blender-git/lib
- svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/linux_centos7_x86_64
build-dockerfile:
image: docker:19.03.12
rules:
- changes:
- build.json
stage: build
services:
- docker:dind
cache:
key: blender-source
script:
- apk add python3
- apk add py3-pip
- python3 -m pip install --upgrade pip
- python3 -m pip install -r requirement-build.txt
- python3 main.py
- python3 main.py --tag=latest
@@ -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>
-68
View File
@@ -1,68 +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)
# Check if this folder exist
RUN ls /opt/build_linux/bin/
## 02. Build optimissed image
## Setup a Multistage optimisation
FROM ubuntu:25.04 AS final
RUN apt-get update && apt-get install -y \
libsm6 \
libxi6 \
libxxf86vm1 \
libxrender1 \
libxfixes3 \
libxkbcommon0 \
libgl1
RUN useradd -m -s /bin/bash bld
USER bld
COPY --from=b3dock /opt/build_linux/bin /opt/blender
# ARG b3d_vs_major
# ENV B3D_ADDON_PATH="/home/bld/.config/blender/${b3d_vs_major}/scripts/addons"
# Working Directory setup
WORKDIR /opt/blender
+4 -18
View File
@@ -1,4 +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)
[![Python Version](https://img.shields.io/badge/python-3.10-brightgreen)](https://www.python.org/)
# Blender Docker # Blender Docker
@@ -24,20 +26,4 @@ Call this function with blender inside this container
````shell ````shell
#!/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
```
```shell
# Taille de l'image
docker image inspect stilobique/blender:5.1.2 --format='{{.Size}}' | numfmt --to=iec
# Dépendances manquantes
docker run --rm --entrypoint /bin/bash stilobique/blender:5.1.2 -c 'ldd /opt/blender/blender | grep "not found" || echo "All deps OK"'
# Test fonctionnel
docker run --rm stilobique/blender:5.1.2 ./blender -b --python-expr "import bpy; print('OK:', bpy.app.version_string)"
```
+33 -1
View File
@@ -1,8 +1,40 @@
{ {
"tags": "tags":
[{ [{
"b3d_vs_major": 5.1, "b3d_vs_major": 3.4,
"b3d_vs_minor": 1
},
{
"b3d_vs_major": 3.4,
"b3d_vs_minor": 0
},
{
"b3d_vs_major": 3.3,
"b3d_vs_minor": 2 "b3d_vs_minor": 2
},
{
"b3d_vs_major": 3.3,
"b3d_vs_minor": 1
},
{
"b3d_vs_major": 3.3,
"b3d_vs_minor": 0
},
{
"b3d_vs_major": 3.2,
"b3d_vs_minor": 1
},
{
"b3d_vs_major": 3.2,
"b3d_vs_minor": 0
},
{
"b3d_vs_major": 3.1,
"b3d_vs_minor": 2
},
{
"b3d_vs_major": 3.1,
"b3d_vs_minor": 0
} }
] ]
} }
-2
View File
@@ -1,2 +0,0 @@
- major: 5.1
minor: 2
+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 /
+7
View File
@@ -0,0 +1,7 @@
FROM alpine AS csv
LABEL Author="stilobique"
LABEL Title="Linux image with subversion and git"
# Install dependencies
RUN apk add git && apk add subversion
+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