7 Commits
Author SHA1 Message Date
stilobique 8445a95233 Disable the CI 2024-05-31 10:09:39 +02:00
stilobique bf4144a84c Add more blender tags 2024-05-25 17:05:51 +02:00
stilobique a104f50532 Add all latest build 2024-05-10 19:19:43 +02:00
stilobique 5cee49a567 Add more docker blender version 2024-05-10 15:12:25 +02:00
stilobique 8ef6d72ffe Clear unused comment 2024-05-09 16:55:40 +02:00
stilobique 5a16e9de93 Update the dockerfile to be functional ? 2024-05-09 16:04:14 +02:00
stilobique e41f332f60 Reset all build list.
Refactoring the docker file to be functional with the new blender platform and update the pycharm run config
2024-05-09 00:21:22 +02:00
15 changed files with 237 additions and 257 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
-66
View File
@@ -1,66 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
style="clip-rule:evenodd;fill-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"
version="1.1"
viewBox="0 0 181 148"
xml:space="preserve"
id="svg4"
sodipodi:docname="blender-docker.svg"
inkscape:version="1.4.4 (dcaf3e7d9e, 2026-05-05)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"><defs
id="defs4" /><sodipodi:namedview
id="namedview4"
pagecolor="#505050"
bordercolor="#ffffff"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="1"
inkscape:deskcolor="#505050"
inkscape:zoom="5.2541436"
inkscape:cx="90.404837"
inkscape:cy="74.036803"
inkscape:window-width="2648"
inkscape:window-height="1350"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="g4" />
<title
id="title1">Blender logo (without text)</title>
<g
transform="matrix(.281 0 0 .281 -41.8 -43.7)"
id="g4"
style="fill:#1c90ed;fill-opacity:1">
<g
transform="matrix(21.6 0 0 21.6 -4857 7665)"
id="g1"
style="fill:none;fill-opacity:1">
<path
d="m243-334c0.106-1.89 1.03-3.56 2.43-4.74 1.37-1.16 3.21-1.87 5.23-1.87 2.01 0 3.85 0.709 5.22 1.87 1.4 1.18 2.32 2.85 2.43 4.74 0.106 1.94-0.675 3.75-2.04 5.09-1.4 1.36-3.38 2.22-5.61 2.22s-4.22-0.854-5.61-2.22c-1.37-1.34-2.15-3.14-2.04-5.08z"
style="fill-rule:nonzero;fill:none;fill-opacity:1"
id="path1" />
</g>
<g
transform="matrix(11.1,0,0,11.1,-2215,4153)"
id="g3"
style="display:inline;fill:#1c90ed;fill-opacity:1">
<path
d="m 243,-334 c 0.106,-1.89 1.03,-3.56 2.43,-4.74 1.37,-1.16 3.21,-1.87 5.23,-1.87 2.01,0 3.85,0.709 5.22,1.87 1.4,1.18 2.32,2.85 2.43,4.74 0.106,1.94 -0.675,3.75 -2.04,5.09 -1.4,1.36 -3.38,2.22 -5.61,2.22 -2.23,0 -4.22,-0.854 -5.61,-2.22 -1.37,-1.34 -2.15,-3.14 -2.04,-5.08 z"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero"
id="path2" />
<path
d="m 231,-330 c 0.013,0.74 0.249,2.18 0.603,3.3 0.744,2.38 2.01,4.58 3.76,6.51 1.8,1.99 4.02,3.59 6.58,4.73 2.69,1.19 5.61,1.8 8.64,1.8 3.03,-0.004 5.95,-0.624 8.64,-1.83 2.56,-1.15 4.78,-2.75 6.58,-4.75 1.76,-1.95 3.02,-4.15 3.76,-6.53 0.375,-1.2 0.612,-2.42 0.707,-3.64 0.093,-1.2 0.054,-2.41 -0.117,-3.62 -0.334,-2.35 -1.15,-4.56 -2.4,-6.56 -1.14,-1.85 -2.62,-3.46 -4.38,-4.82 l 0.004,-0.003 -17.7,-13.6 c -0.016,-0.012 -0.029,-0.025 -0.046,-0.036 -1.16,-0.892 -3.12,-0.889 -4.39,0.005 -1.29,0.904 -1.44,2.4 -0.29,3.34 l -0.005,0.005 7.39,6.01 -22.5,0.024 h -0.03 c -1.86,0.002 -3.65,1.22 -4,2.77 -0.364,1.57 0.9,2.88 2.84,2.88 l -0.003,0.007 11.4,-0.022 -20.4,15.6 c -0.026,0.019 -0.054,0.039 -0.078,0.058 -1.92,1.47 -2.54,3.92 -1.33,5.46 1.23,1.57 3.84,1.58 5.78,0.009 l 11.1,-9.1 c 0,0 -0.162,1.23 -0.149,1.96 z m 28.6,4.11 c -2.29,2.33 -5.5,3.66 -8.96,3.66 -3.47,0.006 -6.68,-1.3 -8.97,-3.63 -1.12,-1.14 -1.94,-2.44 -2.45,-3.83 -0.497,-1.37 -0.69,-2.82 -0.562,-4.28 0.121,-1.43 0.547,-2.8 1.23,-4.03 0.668,-1.21 1.59,-2.31 2.72,-3.24 2.23,-1.81 5.06,-2.8 8.02,-2.8 2.97,-0.004 5.8,0.969 8.03,2.78 1.13,0.924 2.05,2.02 2.72,3.23 0.683,1.23 1.11,2.59 1.23,4.03 0.126,1.46 -0.067,2.91 -0.564,4.28 -0.508,1.4 -1.33,2.7 -2.45,3.84 z"
style="fill:#1c90ed;fill-opacity:1;fill-rule:nonzero"
id="path3" />
</g>
</g>
<metadata
id="metadata4"><rdf:RDF><cc:Work
rdf:about=""><dc:title>Blender logo (without text)</dc:title></cc:Work></rdf:RDF></metadata></svg>

Before

Width:  |  Height:  |  Size: 3.7 KiB

@@ -1,26 +1,33 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build BlenderDocker" type="docker-deploy" factoryName="dockerfile" server-name="Docker Desktop"> <configuration default="false" name="Dockerfile" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile"> <deployment type="dockerfile">
<settings> <settings>
<option name="imageTag" value="stilobique/blender:4.5.11" /> <option name="imageTag" value="stilobique/blender:3.6.12" />
<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="4.5" /> <option name="value" value="3.6" />
</DockerEnvVarImpl> </DockerEnvVarImpl>
<DockerEnvVarImpl> <DockerEnvVarImpl>
<option name="name" value="b3d_vs_minor" /> <option name="name" value="b3d_vs_minor" />
<option name="value" value="11" /> <option name="value" value="12" />
</DockerEnvVarImpl> </DockerEnvVarImpl>
</list> </list>
</option> </option>
<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="Dockerfile" />
<option name="volumeBindings">
<list>
<DockerVolumeBindingImpl>
<option name="containerPath" value="/moderlab-plugin" />
<option name="hostPath" value="E:\Projects\Git\Blender-Moderlab-Config\addons\moderlab-plugin\moderlab-plugin" />
</DockerVolumeBindingImpl>
</list>
</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>
+34
View File
@@ -0,0 +1,34 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Generate image" 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" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<EXTENSION ID="net.ashald.envfile">
<option name="IS_ENABLED" value="false" />
<option name="IS_SUBST" value="false" />
<option name="IS_PATH_MACRO_SUPPORTED" value="false" />
<option name="IS_IGNORE_MISSING_FILES" value="false" />
<option name="IS_ENABLE_EXPERIMENTAL_INTEGRATIONS" value="false" />
<ENTRIES>
<ENTRY IS_ENABLED="true" PARSER="runconfig" />
</ENTRIES>
</EXTENSION>
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.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>
+76 -34
View File
@@ -1,49 +1,91 @@
FROM python:latest AS b3dock FROM ubuntu:22.04 AS blender
# Setup all software version request # Setup all software version request
ARG b3d_vs_major=5.2 ARG b3d_vs_major=3.6
ARG b3d_vs_minor=0 ARG b3d_vs_minor=10
ARG version=v${b3d_vs_major}.${b3d_vs_minor}
LABEL Author="stilobique" LABEL Author="stilobique"
LABEL Title="Blender Docker for Unit Test" LABEL Title="Blender Docker for Unit Test"
LABEL maintainer="Aurelien Vaillant contact@aurelien-vaillant.net"
#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 # Install dependencies
RUN apt-get update && apt-get install -y git git-lfs RUN apt-get update && apt-get install -y build-essential \
git \
git-lfs \
cmake \
python3 \
python3-dev \
cython3 \
sudo
RUN apt-get install -y libx11-dev \
libxxf86vm-dev \
libxcursor-dev \
libxi-dev \
libxrandr-dev \
libxinerama-dev \
libxkbcommon-dev \
libwayland-dev \
libdecor-0-dev \
wayland-protocols \
libdbus-1-dev \
libgl-dev \
libegl-dev
RUN apt-get install -y libjpeg-dev \
libpng-dev \
libfreetype-dev \
libfontconfig-dev \
libzstd-dev \
libbz2-dev \
liblzma-dev \
libsdl2-dev \
libepoxy-dev \
libxml2-dev \
libhpdf-dev \
libpystring-dev
RUN apt-get install -y libopenjp2-7-dev \
libtiff-dev \
libjack-jackd2-dev \
libpulse-dev \
libopenal-dev \
libsndfile1-dev \
libjemalloc-dev \
libvulkan-dev \
libgmp-dev \
libpugixml-dev \
libfftw3-dev \
libpotrace-dev \
libyaml-cpp-dev \
libdeflate-dev
# ADD . /opt/blender-git
RUN git clone --depth 1 --branch ${version} https://projects.blender.org/blender/blender.git /opt/blender-git
# Use the local repo has current directory
#WORKDIR /opt/blender-git
# Compile Blender # Compile Blender
RUN git clone --depth 1 --branch v${b3d_vs_major}.${b3d_vs_minor} \ RUN cd /opt/blender-git && \
https://projects.blender.org/blender/blender.git /opt/blender sudo ./build_files/utils/make_update.py --use-linux-libraries
RUN cd /opt/blender-git && \
make
# Get dependencies
COPY ./scripts/gen_packages_txt.py /opt/blender/build_files/build_environment/gen_packages_txt.py
RUN cd /opt/blender/build_files/build_environment && \
python gen_packages_txt.py
RUN cd /opt/blender/build_files/build_environment && chmod a+x ./install_linux_packages.py && \
python install_linux_packages.py
RUN cd /opt/blender && make update
RUN cd /opt/blender && make -j$(nproc)
## 02. Build optimissed image
## Setup a Multistage optimisation ## Setup a Multistage optimisation
FROM ubuntu:25.04 AS final FROM ubuntu:22.04
COPY --from=blender /opt/build_linux/bin /opt/blender
ARG b3d_vs_major
ENV B3D_ADDON_PATH "$HOME/.config/blender/${b3d_vs_major}/scripts/addons"
COPY --from=b3dock /opt/blender/build_files/build_environment/packages.txt /tmp/packages.txt RUN apt-get update && apt-get install -y \
RUN apt-get update && xargs -a /tmp/packages.txt apt-get install -y libxi6 \
libxxf86vm1 \
RUN useradd -m -s /bin/bash bld libxfixes3 \
libxkbcommon-x11-0 \
USER bld libjack0 \
COPY --from=b3dock /opt/build_linux/bin /opt/blender pulseaudio \
libgl1-mesa-glx
# ARG b3d_vs_major
# ENV B3D_ADDON_PATH="/home/bld/.config/blender/${b3d_vs_major}/scripts/addons"
# Working Directory setup # Working Directory setup
WORKDIR /opt/blender WORKDIR /opt/blender
+4 -18
View File
@@ -1,8 +1,10 @@
[![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.0.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)
# Blender Docker # Blender Docker
This repository is an automated blender docker image file generated, it's usefully with blender addon unit test. This repository is an automated blender docker image file generated, it's usefully with blender addon unit test. To
build a new specific image, you need to update the `build.json` file with the new version witched ; or
# Adding an Addon # Adding an Addon
@@ -24,19 +26,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
```
```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)"
```
View File
-63
View File
@@ -1,63 +0,0 @@
import os
import docker
from .version import BlenderVersion
from pathlib import Path
from docker.errors import BuildError
class BlenderDocker:
def __init__(self, blender: BlenderVersion):
self._blender_version = blender
# Todo get a user config
# self._docker_client = docker.DockerClient(base_url=f'unix://{Path.home()}/.docker/desktop/docker.sock')
self._docker_client = docker.DockerClient(base_url=f'unix:///var/run/docker.sock')
self._docker_image = None
self._docker_file = Path(os.getcwd(), 'Dockerfile')
if not self._docker_file.exists():
print(f'Dockerfile not found: {self._docker_file}')
exit(1)
self.args = {
'b3d_vs_major': f'{self._blender_version.major}',
'b3d_vs_minor': f'{self._blender_version.minor}.{self._blender_version.hotfix}',
}
def build(self):
try:
print('\tBuilding Blender Docker')
print(f'\tWhere to build: {os.getcwd()}')
print(f'\tArgs: {self.args}')
print(f'\tTage generated: {self._blender_version.format_to_tag()}')
build = self._docker_client.images.build(
path=os.getcwd(),
buildargs=self.args,
tag=self._blender_version.format_to_tag(),
quiet=False,
)
print(f'\tBuilding Blender Docker Image done: {build}')
return build
except BuildError as e:
print("Hey something went wrong with image build!")
for line in e.build_log:
if 'stream' in line:
print(line['stream'].strip())
raise
@staticmethod
def tag(self):
print('\tSet Tags version and/or Latest')
pass
@staticmethod
def test(self):
print('\tTesting Blender Docker')
# docker run --rm stilobique/blender:5.1.2 ./blender --version
pass
def push(self):
# TODO Login to hub
pass
-26
View File
@@ -1,26 +0,0 @@
class BlenderVersion:
def __init__(self, version: str = '5.1.0'):
"""
Need an object like 'X.Y.Z' to work correctly, build a pythonic object about a blender version.
:param version:
"""
self.major : str = ''
self.minor : str = ''
self.hotfix : str = ''
self.version_object(version)
def version_object(self, version: str):
"""Set all version properties to a string"""
version = version.split('.')
self.major = version[0]
self.minor = version[1]
self.hotfix = version[2]
def format_to_tag(self) -> str:
"""From version information, format to return a string"""
return f'{self.major}.{self.minor}.{self.hotfix}'
def __str__(self):
return str(self.major + '.' + self.minor + '.' + self.hotfix)
+32
View File
@@ -0,0 +1,32 @@
{
"tags":
[{
"b3d_vs_major": 4.1,
"b3d_vs_minor": 0
},
{
"b3d_vs_major": 3.6,
"b3d_vs_minor": 12
},
{
"b3d_vs_major": 3.6,
"b3d_vs_minor": 11
},
{
"b3d_vs_major": 3.6,
"b3d_vs_minor": 10
},
{
"b3d_vs_major": 3.3,
"b3d_vs_minor": 19
},
{
"b3d_vs_major": 3.3,
"b3d_vs_minor": 18
},
{
"b3d_vs_major": 3.3,
"b3d_vs_minor": 17
}
]
}
+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
+31 -11
View File
@@ -1,10 +1,27 @@
import os import os
import pathlib
from blender.version import BlenderVersion import json
from blender.docker import BlenderDocker import docker
import sys
# TODO Update readme file badge with blender version # TODO Update readme file badge with blender version
# TODO add a check if the image build are stored in the docker register # TODO add a check if the image build are stored in the docker register
def get_data_from_json() -> (str, str):
"""From the json file, get blender version (major and minor), and return this information."""
file = pathlib.Path(os.getcwd(), 'build.json')
with open(file, 'r') as f:
data = json.load(f)
f.close()
version_values = data['tags'][0]
major, minor = version_values['b3d_vs_major'], version_values['b3d_vs_minor']
return major, minor
def build_docker(b3d_version: (str, str), latest: bool = False): def build_docker(b3d_version: (str, str), latest: bool = False):
""" """
Generate docker image, request the blender version (major, minor) with the keyword b3d_version, and can be Generate docker image, request the blender version (major, minor) with the keyword b3d_version, and can be
@@ -35,11 +52,14 @@ def build_docker(b3d_version: (str, str), latest: bool = False):
if __name__ == "__main__": if __name__ == "__main__":
version = BlenderVersion(input("Give the blender version (X.Y.Z): ")) version = get_data_from_json()
print(f'Start -> Setup the package with blender version "{version[0]}.{version[1]}"')
# build_docker(b3d_version=(f'{version.major}', f'{version.minor}.{version.hotfix}'), for arg in sys.argv:
# latest=False) if '--tag=' in arg:
print(f'Build with the tag "{arg}".')
print(f"Build a blender version {version}.") build_docker(b3d_version=version, latest=True)
docker = BlenderDocker(version) break
docker.build() else:
build_docker(b3d_version=version)
print(f'Start to build the docker file.')
pass
+1
View File
@@ -0,0 +1 @@
docker
-1
View File
@@ -1 +0,0 @@
docker==7.2.0
-31
View File
@@ -1,31 +0,0 @@
#!/usr/bin/env python3
"""
Lit install_linux_packages.py et génère un fichier .txt avec les paquets
Debian/Ubuntu à installer.
"""
import re
import sys
READER="install_linux_packages.py"
OUT="packages.txt"
def main():
with open(READER, "r", encoding="utf-8") as f:
content = f.read()
# Cherche toutes les lignes du type: DISTRO_ID_DEBIAN: "nom-du-paquet"
packages = re.findall(r'DISTRO_ID_DEBIAN:\s*"([^"]+)"', content)
# Enlève les doublons, trie
packages = sorted(set(packages))
with open(OUT, "w", encoding="utf-8") as f:
for pkg in packages:
f.write(pkg + "\n")
print(f"{len(packages)} paquets écrits dans {OUT}")
if __name__ == "__main__":
main()