WIP Docker building
This commit is contained in:
@@ -1,45 +1,23 @@
|
||||
import os
|
||||
|
||||
from blender.version import BlenderVersion
|
||||
from blender.docker import BlenderDocker
|
||||
|
||||
# TODO Update readme file badge with blender version
|
||||
# TODO add a check if the image build are stored in the docker register
|
||||
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
|
||||
tagged with latest or only blender version info.
|
||||
"""
|
||||
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'])
|
||||
|
||||
# Init all data to build the docker image
|
||||
args = {
|
||||
'b3d_vs_major': str(b3d_version[0]),
|
||||
'b3d_vs_minor': str(b3d_version[1]),
|
||||
}
|
||||
docker_repo = 'stilobique/blender'
|
||||
if latest:
|
||||
tag = 'latest'
|
||||
else:
|
||||
tag = f'{args["b3d_vs_major"]}.{args["b3d_vs_minor"]}'
|
||||
completed_tag_name = f'{docker_repo}:{args["b3d_vs_major"]}.{args["b3d_vs_minor"]}'
|
||||
|
||||
print('\t1 -> Build from image file')
|
||||
client.images.build(path=os.getcwd(), buildargs=args, tag=completed_tag_name, rm=True, forcerm=True)
|
||||
|
||||
print(f'\t2 -> Push the new images with tag {tag}')
|
||||
push = client.images.push(repository=docker_repo, tag=tag, stream=True)
|
||||
print(f'\t\tDebug push :\n\t\t{push}')
|
||||
# Todo Update readme file badge with blender version
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Todo use the manual entry can be error prone (need to make a basic regex to check this entry)
|
||||
version = BlenderVersion(input("Give the blender version (X.Y.Z): "))
|
||||
|
||||
# build_docker(b3d_version=(f'{version.major}', f'{version.minor}.{version.hotfix}'),
|
||||
# latest=False)
|
||||
|
||||
print(f"Build a blender version {version}.")
|
||||
docker = BlenderDocker(version)
|
||||
docker.build()
|
||||
docker.build()
|
||||
|
||||
print('Test your image.')
|
||||
test = docker.test()
|
||||
|
||||
if test:
|
||||
print('Push this image.')
|
||||
docker.push()
|
||||
|
||||
# Todo: Add a latest tag, check if this version are the latest
|
||||
# Todo: Add a LTS tag, check if this version are a LTS
|
||||
Reference in New Issue
Block a user