From a2f5a9cea33ebc931cff87df1b114615927b3cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Jedlicska?= Date: Fri, 13 Oct 2023 14:49:47 +0200 Subject: [PATCH] rework docker image to run blender headless --- Dockerfile | 17 ++++++++++------- installation/connector.py | 7 +++++++ speckle_import.py | 21 +++++---------------- 3 files changed, 22 insertions(+), 23 deletions(-) create mode 100644 installation/connector.py diff --git a/Dockerfile b/Dockerfile index 09dfadc..a1dedb2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,15 @@ -FROM linuxserver/blender +FROM ubuntu:22.04 -RUN apt update && \ - apt install python3-pip && \ - apt install unzip && \ - pip install poetry +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt update +RUN apt install -y tar wget blender python3-pip + +RUN pip3 install poetry COPY . . RUN poetry export -f requirements.txt --output requirements.txt && pip install -r requirements.txt -RUN curl -o blender-connector.zip https://github.com/specklesystems/speckle-blender/archive/refs/tags/2.16.0-rc1.zip && \ - unzip blender-connector.zip -d "$HOME/.config/blender/3.3/" +# RUN mkdir -p $HOME/.config/blender/3.0/scripts/addons +RUN wget -O blender-connector.zip https://releases.speckle.dev/installers/blender/bpy_speckle-2.17.0-alpha2.zip +RUN blender --background --python installation/connector.py diff --git a/installation/connector.py b/installation/connector.py new file mode 100644 index 0000000..82dee1b --- /dev/null +++ b/installation/connector.py @@ -0,0 +1,7 @@ +import os + +import bpy + +bpy.ops.preferences.addon_install(filepath="/blender-connector.zip") +bpy.ops.preferences.addon_enable(module="bpy_speckle") +bpy.ops.wm.save_userpref() diff --git a/speckle_import.py b/speckle_import.py index 40407b0..815052f 100644 --- a/speckle_import.py +++ b/speckle_import.py @@ -1,9 +1,3 @@ -import bpy -import os - -bpy.ops.preferences.addon_install(filepath='/blender-connector.zip') -bpy.ops.preferences.addon_enable(module='bpy_speckle') - from bpy_speckle.convert.to_native import _deep_conversion from specklepy.api import operations @@ -30,23 +24,18 @@ def set_filename(fileName): _deep_conversion(commit_object, converted_objects, True) - - -all_cameras = [o for o in bpy.context.scene.objects if o.type == 'CAMERA'] +all_cameras = [o for o in bpy.context.scene.objects if o.type == "CAMERA"] total = len(all_cameras) print(f"Starting rendering cameras... 0/{total}") -for (i, ob) in enumerate(all_cameras): - #Set as active render cam +for i, ob in enumerate(all_cameras): + # Set as active render cam bpy.context.scene.camera = ob - #Render camera to output directory + # Render camera to output directory set_filename(f"{ob.name}") - bpy.ops.render.render(write_still = True) + bpy.ops.render.render(write_still=True) print(f"Render {i}/{total} complete! saved at {bpy.context.scene.render.filepath}") print(f"All Done!") - - -