mirror of
https://gitlab.com/stilobique/blender-docker.git
synced 2026-05-27 20:27:47 +02:00
Change the gitlab ci with a python setup
This commit is contained in:
+3
-17
@@ -1,24 +1,10 @@
|
|||||||
image: docker:19.03.12
|
image: docker:19.03.12
|
||||||
|
|
||||||
job-init:
|
|
||||||
stage: .pre
|
|
||||||
script: echo "make something useful before build stage"
|
|
||||||
|
|
||||||
job-build-docker-latest:
|
job-build-docker-latest:
|
||||||
stage: build
|
stage: build
|
||||||
services:
|
services:
|
||||||
- docker:19.03.12-dind
|
- docker:19.03.12-dind
|
||||||
script:
|
script:
|
||||||
- apk update && apk add curl jq python3 py3-pip
|
- python -m pip install --upgrade pip
|
||||||
- export export MAJOR=$(jq -r .b3d_vs_major build.json)
|
- python -m pip install -r requirement-build.txt
|
||||||
- export export MINOR=$(jq -r .b3d_vs_minor build.json)
|
- python main.py
|
||||||
- echo Blender version are $MAJOR
|
|
||||||
- echo The Minor blender version are $MINOR
|
|
||||||
- docker login --username stilobique --password $docker_hub_password
|
|
||||||
- docker build --build-arg b3d_vs_major=$MAJOR --build-arg b3d_vs_minor=$MINOR --tag stilobique/blender:$MAJOR.$MINOR .
|
|
||||||
- docker push
|
|
||||||
|
|
||||||
#job-build-docker-tag:
|
|
||||||
# stage: build
|
|
||||||
# script:
|
|
||||||
# - docker build -t stilobique/blender:latest
|
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
import json
|
||||||
|
import docker
|
||||||
|
|
||||||
|
|
||||||
|
def get_data_from_json() -> (str, str):
|
||||||
|
file = pathlib.Path(os.getcwd(), 'build.json')
|
||||||
|
data: dict = {}
|
||||||
|
|
||||||
|
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']
|
||||||
|
print(f'Compile blender version "{major}.{minor}"')
|
||||||
|
|
||||||
|
return major, minor
|
||||||
|
|
||||||
|
|
||||||
|
def build_docker(b3d_version: (str, str)):
|
||||||
|
client = docker.from_env()
|
||||||
|
if os.environ.get('docker_hub_password'):
|
||||||
|
user = os.environ['docker_hub_user']
|
||||||
|
password = os.environ['docker_hub_password']
|
||||||
|
client.login(username=user, password=password)
|
||||||
|
|
||||||
|
# Init all data to build the docker image
|
||||||
|
args = {
|
||||||
|
'b3d_vs_major': str(b3d_version[0]),
|
||||||
|
'b3d_vs_minor': str(b3d_version[1]),
|
||||||
|
}
|
||||||
|
tag_name = f'stilobique/blender:{args["b3d_vs_major"]}.{args["b3d_vs_minor"]}'
|
||||||
|
|
||||||
|
b3d_image = client.images.build(path="./", buildargs=args, tag=tag_name)
|
||||||
|
b3d_image.push()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print('1 -> Setup the package')
|
||||||
|
version = get_data_from_json()
|
||||||
|
print('2 -> Build from image file')
|
||||||
|
build_docker(version)
|
||||||
|
print('3 -> Push the new images')
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
docker
|
||||||
Reference in New Issue
Block a user